/* App styling on top of Basecoat. Components/tokens come from vendor/basecoat.min.css. */
:root {
  --sidebar-w: 250px;
}
body {
  background: var(--background, #fff);
  color: var(--foreground, #111);
}

/* ── Docs-style shell: fixed left sidebar + scrolling content ──────── */
.app-shell {
  min-height: 100vh;
}
.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1rem 0.85rem;
  border-right: 1px solid var(--border, #e5e7eb);
  background: var(--card, #fafafa);
  overflow-y: auto;
}
.app-content {
  margin-left: var(--sidebar-w);
  padding: 1.75rem 2rem 4rem;
  display: grid;
  gap: 1rem;
  align-content: start;
}

/* ── Fixed app topbar: title + metadata, spans the content column ──── */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  margin: -1.75rem -2rem 0.25rem;
  padding: 0.8rem 2rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 4.25rem;
  background: color-mix(in oklab, var(--background, #fff) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.app-topbar h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.tool-meta {
  font-size: 0.82rem;
  color: var(--muted-foreground, #71717a);
}
.tool-meta:empty {
  display: none;
}
.app-topbar h1 + .tool-meta {
  padding-left: 0.7rem;
  border-left: 1px solid var(--border, #e5e7eb);
}

/* Right-aligned sub-view link (Potential ⇄ Ignored duplicates) */
.subnav-link {
  margin-left: auto;
  border: none;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--primary, #18181b);
  border-radius: 0.4rem;
}
.subnav-link:hover {
  background: var(--accent, #f4f4f5);
}
.subnav-link:focus-visible {
  outline: 2px solid var(--ring, #a1a1aa);
  outline-offset: 1px;
}

/* Info popover: description tucked behind an (i) icon */
.info-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 999px;
  background: transparent;
  cursor: help;
  padding: 0;
  color: var(--muted-foreground, #71717a);
}
.info-btn:hover,
.info-btn:focus-visible {
  background: var(--accent, #f4f4f5);
  color: var(--foreground, #111);
  outline: none;
}
.info-pop {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: max-content;
  max-width: 340px;
  z-index: 40;
  background: var(--popover, var(--card, #fff));
  color: var(--popover-foreground, inherit);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 0.65rem;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.16);
  padding: 0.6rem 0.72rem;
  font-size: 0.82rem;
  line-height: 1.5;
  font-weight: 400;
  text-align: left;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  pointer-events: none;
  transition:
    opacity 0.12s ease,
    transform 0.12s ease;
}
.info-pop strong {
  font-weight: 600;
}
.info-btn:hover .info-pop,
.info-btn:focus-visible .info-pop,
.info-btn:focus-within .info-pop {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.sidebar-brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.25rem 0.5rem 0.5rem;
  font-weight: 600;
}
.brand-caret {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--muted-foreground, #71717a);
  padding: 0.2rem;
  border-radius: 0.4rem;
  cursor: pointer;
}
.brand-caret:hover {
  background: var(--accent, #f4f4f5);
  color: inherit;
}
/* Opens downward, anchored to the brand row. */
.brand-menu {
  position: absolute;
  top: calc(100% + 0.1rem);
  right: 0.5rem;
  left: 0.5rem;
  z-index: 30;
  background: var(--popover, var(--card, #fff));
  color: var(--popover-foreground, inherit);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 0.6rem;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.14);
  padding: 0.25rem;
  display: grid;
  gap: 1px;
}
.brand-menu-account {
  display: grid;
  gap: 0.05rem;
  padding: 0.4rem 0.55rem;
  margin-bottom: 0.15rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.brand-menu-account-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted-foreground, #71717a);
}
.brand-menu-account-name {
  font-size: 0.85rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0.42rem 0.55rem;
  border-radius: 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  color: inherit;
}
.brand-menu-item:hover {
  background: var(--accent, #f4f4f5);
}
.brand-logo {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  object-fit: contain;
}
.brand-name {
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.sidebar-nav,
.sidebar-section {
  display: grid;
  gap: 0.15rem;
}
.sidebar-heading {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted-foreground, #71717a);
  padding: 0 0.6rem;
  margin-bottom: 0.3rem;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  text-align: left;
  padding: 0.42rem 0.6rem;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  background: transparent;
  color: var(--foreground, #111);
}
.sidebar-item svg {
  color: var(--muted-foreground, #71717a);
  flex: 0 0 auto;
}
.sidebar-item:hover:not(:disabled) {
  background: var(--accent, #f4f4f5);
}
.sidebar-item.active {
  background: var(--accent, #f4f4f5);
  font-weight: 500;
}
.sidebar-item.active svg {
  color: var(--foreground, #111);
}
.sidebar-item:disabled {
  color: var(--muted-foreground, #a1a1aa);
  cursor: default;
}

/* Filters section (secondary controls, under the nav) */

#filter-activity {
  gap: 0;
}
.sidebar-section .filter-group {
  display: grid;
  gap: 0.5rem;
  padding: 0 0.6rem;
  margin-bottom: 0.4rem;
}
.filter-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 500;
}
.sidebar-section .control {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.87rem;
  padding: 0.2rem 0.6rem;
}
.sidebar-section #min-score {
  width: 100%;
}
.slider-ends {
  display: flex;
  justify-content: space-between;
  margin-top: -0.3rem;
  font-size: 0.72rem;
  color: var(--muted-foreground, #71717a);
}
.sidebar-section #search {
  width: calc(100% - 1.2rem);
  margin: 0.4rem 0.6rem 0;
}

.sidebar-spacer {
  flex: 1;
}
.sidebar-sync {
  display: grid;
  gap: 0.55rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border, #e5e7eb);
}
.sidebar-sync #sync-status {
  font-size: 0.76rem;
  line-height: 1.35;
}
.split-button {
  position: relative;
  display: flex;
  align-items: stretch;
}
.split-button .sync-main {
  flex: 1;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.sync-more {
  display: flex;
}
.split-button .sync-caret {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: 1px solid
    color-mix(in oklab, var(--primary-foreground, #fff) 25%, transparent);
  padding-inline: 0.35rem;
}
/* Opens upward, spans the full split-button width, stays inside the sidebar. */
.sync-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 0.4rem);
  z-index: 30;
  background: var(--popover, var(--card, #fff));
  color: var(--popover-foreground, inherit);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 0.6rem;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.14);
  padding: 0.25rem;
  display: grid;
  gap: 1px;
}
.sync-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0.42rem 0.55rem;
  border-radius: 0.4rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: inherit;
}
.sync-menu-item:hover {
  background: var(--accent, #f4f4f5);
}

/* ── Content: tool panels ─────────────────────────────────────────── */
.tool-panel {
  display: grid;
  gap: 0.85rem;
}

/* ── Empty states ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 0.85rem;
  padding: 3rem 1rem;
  max-width: 34rem;
  margin: 1.5rem auto;
}
.page-empty {
  min-height: 100vh;
  align-content: center;
  max-width: 40rem;
}
.empty-icon {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--muted, #f4f4f5);
  color: var(--muted-foreground, #71717a);
}
.empty-state h1,
.empty-state h2 {
  margin: 0;
  letter-spacing: -0.02em;
}
.empty-lead {
  color: var(--muted-foreground, #6b7280);
  max-width: 46ch;
  margin: 0;
  line-height: 1.6;
}
.empty-state .btn,
.empty-state .btn-lg {
  margin-top: 0.35rem;
}
#config-warning {
  margin-inline: auto;
}

/* ── Progress: centered modal (visible regardless of scroll) ──────── */
.progress-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in oklab, var(--foreground, #111) 45%, transparent);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.progress-modal[hidden] {
  display: none;
}
.progress-modal-card {
  width: min(90vw, 380px);
  display: grid;
  gap: 0.9rem;
  padding: 1.5rem 1.6rem;
  background: var(--card, #fff);
  color: var(--foreground, #111);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 0.85rem;
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.28);
}
.progress-modal-card #progress-text {
  text-align: center;
}
.progress {
  flex: 1;
  height: 8px;
  background: var(--secondary, #f1f1f4);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--primary, #18181b);
  border-radius: 999px;
  transition: width 0.2s ease;
}
.progress-fill.indeterminate {
  width: 35%;
  animation: app-indeterminate 1.1s infinite ease-in-out;
}
@keyframes app-indeterminate {
  0% {
    margin-left: -35%;
  }
  100% {
    margin-left: 100%;
  }
}
#progress-text {
  white-space: nowrap;
  font-size: 0.85rem;
}

/* ── Pair cards ───────────────────────────────────────────────────── */

/* Match-strength badge: neutral outline pill with a small colored strength pip. */
.match-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.match-pip {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  flex: 0 0 auto;
}

/* All result cards share one width, centered in the results column. */
.card {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}
.pair-card {
  padding: 20px;
}

/* Footer: badge + actions below a hairline. Its top padding equals the card's
   bottom padding (20px) so the button row is vertically symmetric; no side
   padding, so badges/actions align with the card content. */
.pair-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1.1rem;
  padding: 20px 0 0;
  border-top: 1px solid var(--border, #e5e7eb);
}
/* List-card footer sits directly on top of the last row (0px gap above it). */
.list-card .pair-footer {
  margin-top: 0;
}
.pair-actions {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
}
/* Override basecoat's card-section padding so columns align to the card's own
   20px inset (and thus with the footer badges/actions). */
.pair-card .pair-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  padding: 0;
}
.person h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  font-weight: 500;
}
.person dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.75rem;
  font-size: 0.88rem;
}
.person dt {
  color: var(--muted-foreground, #6b7280);
}
.person dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.person dd .field-line {
  display: block;
}
/* A field that conflicts with the other record (flagged on the right column). */
.person dd.field-mismatch {
  color: #c2410c; /* orange-700 */
}
.person dd.field-mismatch::after {
  content: " ×";
  color: #ea580c; /* orange-600 */
}
/* Name links to PCO; ↗ arrow fades/slides in on hover. */
.person-name-link {
  color: var(--foreground, #111);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}
.person-name-link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.name-arrow {
  opacity: 0;
  transform: translate(-2px, 2px);
  color: var(--muted-foreground, #71717a);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.person-name-link:hover .name-arrow,
.person-name-link:focus-visible .name-arrow {
  opacity: 1;
  transform: translate(0, 0);
}
.pair-card.decided {
  opacity: 0.5;
}
@media (max-width: 700px) {
  .pair-card .pair-grid {
    grid-template-columns: 1fr;
  }
}

/* ── List cards (Shared logins + Households): title, clickable rows, footer ── */
.list-card {
  padding: 20px;
  gap: 0;
}
.list-card-title {
  font-weight: 500;
  font-size: 1rem;
  overflow-wrap: anywhere;
  margin-bottom: 0.35rem;
}
.row-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.row-list li + li {
  border-top: 1px solid var(--border, #eee);
}
/* Whole row links to the person in PCO. Aligned to the 20px card padding; the
   hover highlight spans the content width without bleeding past it. */
.row-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
  font-size: 0.9rem;
  color: inherit;
  text-decoration: none;
}
.row-link:hover .row-name {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.row-name {
  font-weight: 400;
}
.row-meta {
  color: var(--muted-foreground, #6b7280);
  font-size: 0.85rem;
  white-space: nowrap;
}
.pip-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 400;
}
.pip {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  flex: 0 0 auto;
}

/* ── List spacing ─────────────────────────────────────────────────── */
#results,
#security-results,
#household-results {
  display: grid;
  gap: 0.85rem;
  align-content: start;
}
.results-note {
  color: var(--muted-foreground, #6b7280);
  font-size: 0.88rem;
  padding: 0.5rem 0;
}

/* Mobile: sidebar stacks on top */
@media (max-width: 760px) {
  .app-sidebar {
    position: static;
    width: auto;
    border-right: none;
    border-bottom: 1px solid var(--border, #e5e7eb);
  }
  .app-content {
    margin-left: 0;
    padding: 1.25rem;
  }
  .app-topbar {
    margin: -1.25rem -1.25rem 0.25rem;
    padding: 0.7rem 1.25rem;
  }
  .sidebar-spacer {
    display: none;
  }
}

/* ── PCO write error banner ───────────────────────────────────────── */
.write-error {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.write-error #write-error-msg {
  flex: 1;
}
