/* ----------------------------------------
   BASE DEFAULTS (global element backstop for non-.pw-layout views)
   Pages using .pw-layout get base.css styles instead.

   PWP-194 disposition: this block is a PERMANENT backstop, not migration
   debt. It styles bare elements on Devise/auth views, the member layout,
   and any other page that hasn't opted into .pw-layout. Do not delete
   rules here without confirming the affected element has a component
   owner AND every consumer has migrated to that component. The member
   layout's eventual move to .pw-layout is M(tail) territory.
---------------------------------------- */
body {
  font-family: var(--pw-font-sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--pw-color-text);
  background: var(--pw-color-surface-base);
}

.container {
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 1.5rem;
}

a {
  color: var(--pw-color-link);
  text-decoration: none;
}

a:hover {
  color: var(--pw-color-link-hover);
  text-decoration: underline;
}

/* No margin here: reset.css zeroes heading margins, and spacing comes from
   the surrounding layout rules. */
h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.1rem; }

/* Basic form field styling for non-migrated pages */
label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"], [type="reset"]),
select,
textarea {
  display: block;
  width: 100%;
  font-family: var(--pw-font-sans);
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--pw-color-border);
  border-radius: 6px;
  background: var(--pw-color-input-bg);
  color: var(--pw-color-text);
  margin-bottom: 1rem;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--pw-color-focus-border);
  box-shadow: 0 0 0 3px var(--pw-color-focus-ring);
}

/* Monospace readonly display variant for non-editable text inputs, e.g. the
   sign-in link URL. Generic so any input tagged with this class picks it up
   regardless of layout context. */
input.pw-monospace-display {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: var(--pw-text-sm);
  color: var(--pw-color-text-muted);
  margin-bottom: var(--pw-space-2);
}

/* Rails wraps fields with validation errors in <div class="field_with_errors">.
   Inside FormFieldComponent the wrapper is harmless (the --invalid class on
   the root drives the visual). On non-FormField forms (Devise auth views) the
   wrapper would otherwise become a block div between label and input on error
   paths. display: contents keeps it transparent to layout. The .pw-layout-
   scoped border/focus rules retired in PWP-197 — this is just the layout shim. */
.field_with_errors {
  display: contents;
}

/* Basic table styling for non-migrated pages */
table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--pw-color-text-muted);
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--pw-color-border);
}

td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--pw-color-border);
  font-size: 0.875rem;
}

/* Dashboard cards for non-migrated pages */
article {
  background: var(--pw-color-surface-sunken);
  border: 1px solid var(--pw-color-border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}


/* ----------------------------------------
   APP SHELL
   Chrome background with a chrome-accent bottom rule — applied to admin
   and application layouts. Member layout's body[data-namespace="member"]
   override swaps in the member-chrome background and rule, so a leader can
   tell the two sides apart at a glance. The chrome-text, -text-muted,
   -border and -hover-bg rules below apply to both headers on purpose;
   spec/design_tokens_spec.rb checks the text pairs on both backgrounds.
---------------------------------------- */
body > header {
  background: var(--pw-color-chrome-bg);
  border-bottom: 3px solid var(--pw-color-chrome-accent);
  padding-block: 0;
  margin-bottom: 0;
}

body > header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--pw-space-2);
  padding-block: var(--pw-space-3);
}

/* Member namespace header. Shares the chrome text rules with admin (see
   APP SHELL above); the background, rule and ghost-button hover fill differ.
   The hover overrides sit with the user menu rules below. */
body[data-namespace="member"] > header {
  background: var(--pw-color-member-chrome-bg);
  border-bottom: 3px solid var(--pw-color-member-chrome-accent);
}

/* Logo link in every header (admin, application, member) */
.site-logo-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.site-logo-link:hover {
  text-decoration: none;
}

.site-logo-link .pw-logo {
  height: 1.75rem;  /* also in public/*.html (.logo-band img) and the /a/brand nav preview */
  width: auto;
  display: block;
}

/* Header nav: chrome-text links, no padding, no underline until hover.
   The active item's poppy underline lives in nav_link_component.css. */
.app-nav {
  display: flex;
  gap: var(--pw-space-3);
  align-items: center;
  font-size: var(--pw-text-md);
  font-weight: var(--pw-weight-medium);
}

/* Plain anchors inside .app-nav (e.g., the org label, member-layout links
   that haven't migrated to NavLinkComponent yet) inherit the chrome text
   color. NavLinkComponent owns its own active styling — see
   nav_link_component.css. */
.app-nav a {
  color: var(--pw-color-chrome-text);
  text-decoration: none;
  transition: color 0.15s;
}

/* Line only, not the shorthand, so it never resets the active item's
   underline color (see nav_link_component.css). */
.app-nav a:hover {
  text-decoration-line: underline;
}

/* org-label sits dimmed at right edge of nav, separated by a vertical rule */
.app-nav .org-label {
  font-size: var(--pw-text-sm);
  color: var(--pw-color-chrome-text-muted);
  font-weight: var(--pw-weight-normal);
  padding-left: var(--pw-space-4);
  border-left: 1px solid var(--pw-color-chrome-border);
  margin-left: var(--pw-space-2);
  text-decoration: none;
}

.app-nav .org-label:hover {
  color: var(--pw-color-chrome-text);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: var(--pw-space-3);
  padding-left: var(--pw-space-5);
  border-left: 1px solid var(--pw-color-chrome-border);
  margin-left: var(--pw-space-3);
}

.namespace-toggle {
  font-size: var(--pw-text-xs);
  font-weight: var(--pw-weight-medium);
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--pw-color-chrome-border);
  border-radius: var(--pw-radius-full);
  color: var(--pw-color-chrome-text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.namespace-toggle:hover {
  background: var(--pw-color-chrome-hover-bg);
  border-color: var(--pw-color-chrome-text-muted);
  color: var(--pw-color-chrome-text);
  text-decoration: none;  /* override the global a:hover { text-decoration: underline } */
}

.user-name {
  font-size: var(--pw-text-sm);
  color: var(--pw-color-chrome-text-muted);
  white-space: nowrap;
}

/* Ghost sign-out button. (0,1,2) beats the global BUTTONS rule (0,1,1), and
   its hover (0,2,2) beats the global hover (0,2,1), so only the shape
   (weight, inline-flex, transition) comes from the global set.
   border shorthand sets width + style + color so browser defaults don't bleed
   the outset bevel through (border-color alone leaves width/style at UA defaults). */
body .user-menu button {
  font-size: var(--pw-text-xs);
  padding: 0.3rem 0.75rem;
  background-color: transparent;
  border: 1px solid var(--pw-color-chrome-border);
  color: var(--pw-color-chrome-text-muted);
}

body .user-menu button:hover {
  background-color: var(--pw-color-chrome-hover-bg);
  border: 1px solid var(--pw-color-chrome-text-muted);
  color: var(--pw-color-chrome-text);
}

/* Member header hover fills. The attribute selector out-ranks both admin
   hover rules above, so only the fill changes. */
body[data-namespace="member"] .namespace-toggle:hover {
  background-color: var(--pw-color-member-chrome-hover-bg);
}

body[data-namespace="member"] .user-menu button:hover {
  background-color: var(--pw-color-member-chrome-hover-bg);
}


/* ----------------------------------------
   BUTTONS
   One global rule set for every layout: admin, member, auth and the
   headers (PWP-213). It used to be split between base.css (.pw-layout,
   admin only) and a body-scoped copy here, and the copy had drifted.

   Specificity. :is() takes its most specific argument, so the base rule
   is a flat (0,1,1) for every element and its hover (0,2,1).
   - Anchor buttons get their own selector, body a[role="button"] (0,1,2)
     and hover (0,2,2), to beat base.css's .pw-layout a (0,1,1) and
     .pw-layout a:hover (0,2,1) on specificity rather than load order.
     (base.css used to load a second time after this file, through
     `stylesheet_link_tag :app`; spec/requests/layout_head_links_spec.rb
     now pins one load each.)
   - .outline (0,2,1) ties with the base hover, so it comes after it.
   - .pw-btn-* variants (.pw-layout button.pw-btn-x, 0,2,1) tie with the
     base hover, so they come after it too.
   spec/css_buttons_spec.rb pins this order.

   The base, hover, outline, size and no-underline rules are global. The
   .pw-btn-* color variants stay .pw-layout-scoped (admin only): every call
   site is in admin today. A member or auth view that needs one must widen
   its selector first, or it renders as a primary button. Each variant
   covers both <button> and <a> (a.pw-btn-x is (0,2,1), above the anchor
   base rule's (0,1,2); its hover (0,3,1) beats the anchor hover (0,2,2)).
---------------------------------------- */
body :is(button, [type="button"], [type="submit"], [type="reset"], [role="button"]),
body a[role="button"] {
  display: inline-flex;
  align-items: center;
  gap: var(--pw-space-2);
  font-family: var(--pw-font-sans);
  font-size: var(--pw-text-base);
  font-weight: var(--pw-weight-medium);
  padding: 0.45rem 1.25rem;
  border: 1px solid var(--pw-color-action-primary);
  border-radius: var(--pw-radius-full);
  background: var(--pw-color-action-primary);
  color: var(--pw-color-action-primary-text);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

body :is(button, [type="button"], [type="submit"], [type="reset"], [role="button"]):hover,
body a[role="button"]:hover {
  background: var(--pw-color-action-primary-hover);
  border-color: var(--pw-color-action-primary-hover);
  color: var(--pw-color-action-primary-text);
}

/* Outline variant: transparent fill with action-outline border and text.
   The hover must reset the fill, or the base hover paints it. */
body :is(button, [type="button"], [type="submit"], [type="reset"], [role="button"]).outline {
  background: transparent;
  border-color: var(--pw-color-action-outline);
  color: var(--pw-color-action-outline);
}

body :is(button, [type="button"], [type="submit"], [type="reset"], [role="button"]).outline:hover {
  background: transparent;
  border-color: var(--pw-color-action-outline-hover);
  color: var(--pw-color-action-outline-hover);
}

/* Anchors styled as buttons never underline on hover. Catches role="button",
   .outline and any .pw-btn-* variant (attribute substring match). */
body a[role="button"]:hover,
body a.outline:hover,
body a[class*="pw-btn-"]:hover {
  text-decoration: none;
}

/* Small size modifier. (0,2,1) / anchors (0,2,2) beat the base rule.
   It comes before the .pw-btn-* variants, so a variant's own font-size
   (.pw-btn-undo's text-xs) still wins. */
body :is(button, [type="button"], [type="submit"], [type="reset"], [role="button"]).pw-btn-sm,
body a[role="button"].pw-btn-sm {
  font-size: var(--pw-text-sm);
  padding: var(--pw-space-1) var(--pw-space-3);
}

/* Success variant: success-status fill for positive/restorative actions.
   (0,2,1) ties with the base hover above and wins by coming after it; for
   anchors the base hover is (0,2,2), so the success :hover rule (0,3,1)
   carries the hover state. */
.pw-layout a.pw-btn-success,
.pw-layout button.pw-btn-success,
.pw-layout [role="button"].pw-btn-success {
  background-color: var(--pw-color-status-success-fg);
  border-color: var(--pw-color-status-success-border);
  color: var(--pw-color-text-on-fill);
}

.pw-layout a.pw-btn-success:hover,
.pw-layout button.pw-btn-success:hover,
.pw-layout [role="button"].pw-btn-success:hover {
  background-color: var(--pw-color-status-success-fg-hover);
  border-color: var(--pw-color-status-success-fg-hover);
  color: var(--pw-color-text-on-fill);
  text-decoration: none;
}


/* ----------------------------------------
   PAGE LAYOUT
---------------------------------------- */
/* Non-admin pages only: the admin <main> takes its padding from base.css's
   main.pw-layout. */
main.container:not(.pw-layout) {
  padding-top: 2.25rem;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-header h1,
.page-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Description lists — labeled data fields on detail/show pages */
dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.35rem 1.25rem;
  margin-bottom: 1.5rem;
}

dt {
  color: var(--pw-color-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  padding-top: 0.1rem;
}

dd {
  margin: 0;
}


/* ----------------------------------------
   PAGE FOOTER NAV
   Separates back/edit navigation from page content
---------------------------------------- */
.page-footer-nav {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--pw-color-border);
}


/* ----------------------------------------
   TABLES
---------------------------------------- */
table {
  margin-bottom: 0;
}

.member-type {
  display: block;
  font-size: 0.8rem;
  color: var(--pw-color-text-muted);
  font-weight: 400;
}

.pill {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15rem 0.6rem;
  border-radius: 100px;
  border: 1px solid transparent;
  font-weight: 500;
}

.pill-yes,
.pill-success {
  background: var(--pw-color-status-success-bg);
  color: var(--pw-color-status-success-fg);
  border-color: var(--pw-color-status-success-fg);
}

.pill-no {
  background: var(--pw-color-status-error-bg);
  color: var(--pw-color-status-error-fg);
  border-color: var(--pw-color-status-error-fg);
}

.pill-maybe,
.pill-warning {
  background: var(--pw-color-status-warning-bg);
  color: var(--pw-color-status-warning-fg);
  border-color: var(--pw-color-status-warning-fg);
}

.pill-info {
  background: var(--pw-color-status-info-bg);
  color: var(--pw-color-status-info-fg);
  border-color: var(--pw-color-status-info-fg);
}

h1 .pill {
  font-size: 0.85rem;
  vertical-align: middle;
}

.rsvp-status {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.rsvp-status .pill {
  font-size: 0.9rem;
  padding: 0.25rem 0.85rem;
}

.pill-pulse {
  animation: pill-pulse 2s ease-in-out infinite;
}

@keyframes pill-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.dot-pulse {
  animation: dot-pulse 1.4s infinite;
  opacity: 0;
}
.dot-pulse:nth-child(1) { animation-delay: 0s; }
.dot-pulse:nth-child(2) { animation-delay: 0.2s; }
.dot-pulse:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-pulse {
  0%, 80%, 100% { opacity: 0; }
  40% { opacity: 1; }
}

.row-actions {
  display: flex;
  gap: 0.875rem;
  white-space: nowrap;
}

.row-actions a {
  font-size: 0.875rem;
}

/* ----------------------------------------
   HEALTH TIMELINE
   14-day rolling status display for integration health.
---------------------------------------- */

.health-timeline {
  display: flex;
  gap: 0.25rem;
  margin: 1rem 0;
}

.health-day {
  width: 2.5rem;
  height: 2.75rem;
  border-radius: 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  cursor: default;
  line-height: 1.1;
}

.health-day-month {
  font-size: 0.55rem;
  text-transform: uppercase;
}

.health-day-date {
  font-size: 0.75rem;
}

.health-day-passed {
  background: var(--pw-color-status-success-bg);
  color: var(--pw-color-status-success-fg);
}

.health-day-failed {
  background: var(--pw-color-status-error-bg);
  color: var(--pw-color-status-error-fg);
}

.health-day-mixed-recovered {
  background: var(--pw-color-status-warning-bg);
  color: var(--pw-color-status-success-fg);
}

.health-day-mixed-failing {
  background: var(--pw-color-status-warning-bg);
  color: var(--pw-color-status-error-fg);
}

.health-day-none {
  background: var(--pw-color-status-neutral-bg);
  color: var(--pw-color-status-neutral-fg);
}

/* ----------------------------------------
   PULL STATUS CARDS
   State display for integration pull operations.
---------------------------------------- */

.pw-status-card {
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  border-left: 4px solid;
  margin: 1rem 0;
}

.pw-status-card h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.pw-status-card p {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
}

.pw-status-card--info {
  background: var(--pw-color-status-info-bg);
  border-color: var(--pw-color-status-info-fg);
  color: var(--pw-color-status-info-fg);
}

.pw-status-card--success {
  background: var(--pw-color-status-success-bg);
  border-color: var(--pw-color-status-success-fg);
  color: var(--pw-color-status-success-fg);
}

.pw-status-card--error {
  background: var(--pw-color-status-error-bg);
  border-color: var(--pw-color-status-error-fg);
  color: var(--pw-color-status-error-fg);
}

.pw-status-card--warning {
  background: var(--pw-color-status-warning-bg);
  border-color: var(--pw-color-status-warning-fg);
  color: var(--pw-color-status-warning-fg);
}

.pw-pulse-indicator {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
  animation: pw-pulse 1.5s ease-in-out infinite;
  margin-top: 0.5rem;
}

@keyframes pw-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.pw-timestamp {
  font-size: 0.75rem;
  opacity: 0.7;
}

/* ----------------------------------------
   PULL ITEM CARDS
   Per-member cards for pull processing UI.
---------------------------------------- */

/* Base card */
.pull-item-card {
  display: flex;
  align-items: stretch;
  background: var(--pw-color-surface-sunken);
  border: 1px solid var(--pw-color-border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  overflow: hidden;
}

/* Applied cards are visually quieter */
.pull-item-card--applied {
  opacity: 0.6;
}

.pull-item-data {
  flex: 1;
  min-width: 0;
  padding: 0.75rem 1rem;
}

.pull-item-name {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.pull-item-type {
  font-size: var(--pw-text-sm);
  color: var(--pw-color-text-muted);
}

.pull-item-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pw-space-1) var(--pw-space-3);
  margin-top: var(--pw-space-1);
}

.pull-item-field {
  font-size: var(--pw-text-xs);
  color: var(--pw-color-text-muted);
}

.pull-item-detail {
  font-size: var(--pw-text-sm);
  color: var(--pw-color-text-muted);
  margin: var(--pw-space-1) 0 0;
}

/* Actions column — min-width so all cards align; grows for long person names */
.pull-item-actions-column {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.375rem;
  flex-shrink: 0;
  flex-grow: 0;
  min-width: 18rem;
  padding: 0.75rem 1rem;
  border-left: 1px solid var(--pw-color-border);
}

/* Stack card vertically on narrow viewports */
@media (max-width: 640px) {
  .pull-item-card {
    flex-direction: column;
  }

  .pull-item-actions-column {
    min-width: 0;
    border-left: none;
    border-top: 1px solid var(--pw-color-border);
  }
}

/* Action column color fills for marked/applied states */
.pull-item-card--attach .pull-item-actions-column {
  background: var(--pw-color-status-info-bg);
  border-left-color: var(--pw-color-status-info-border);
}

.pull-item-card--create .pull-item-actions-column {
  background: var(--pw-color-status-success-bg);
  border-left-color: var(--pw-color-status-success-border);
}

.pull-item-card--skip .pull-item-actions-column {
  background: var(--pw-color-surface-sunken);
  border-left-color: var(--pw-color-border);
}

.pull-action-row {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.pull-action-row select {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
}

/* Resolution labels — consistent icon + text for marked & applied states */
.pull-item-resolution {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  margin-bottom: 0.25rem;
}

.pull-resolution-label {
  display: flex;
  align-items: center;
  gap: var(--pw-space-1);
  font-size: var(--pw-text-sm);
  font-weight: var(--pw-weight-medium);
}

.pull-resolution--attach { color: var(--pw-color-status-info-fg); }
.pull-resolution--create { color: var(--pw-color-status-success-fg); }
.pull-resolution--skip { color: var(--pw-color-text-muted); }

.pull-resolution-target {
  font-size: var(--pw-text-sm);
  color: var(--pw-color-text-muted);
  padding-left: var(--pw-space-5);
}

/* Undo button — neutral, low-emphasis */
.pw-layout a.pw-btn-undo,
.pw-layout button.pw-btn-undo {
  background: transparent;
  color: var(--pw-color-text-muted);
  border: 1px solid var(--pw-color-border);
  font-size: var(--pw-text-xs);
}

.pw-layout a.pw-btn-undo:hover,
.pw-layout button.pw-btn-undo:hover {
  background: var(--pw-color-surface-sunken);
  color: var(--pw-color-text-muted);
  border-color: var(--pw-color-border);
}

.pull-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  background: var(--pw-color-surface-sunken);
  border: 1px solid var(--pw-color-border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
}

.pull-meta-details p {
  margin: 0 0 var(--pw-space-1);
  font-size: var(--pw-text-base);
}


.pull-meta-actions {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  flex-shrink: 0;
}

.pull-bulk-actions {
  display: flex;
  gap: 0.375rem;
}

.pw-layout a.pw-btn-secondary,
.pw-layout button.pw-btn-secondary {
  background: var(--pw-color-surface-sunken);
  color: var(--pw-color-text);
  border: 1px solid var(--pw-color-border);
}

.pw-layout a.pw-btn-secondary:hover,
.pw-layout button.pw-btn-secondary:hover {
  background: var(--pw-color-surface-sunken-hover);
  color: var(--pw-color-text);
  border-color: var(--pw-color-border);
}

/* Danger variant — error-status outline for destructive/cancel actions. */
.pw-layout a.pw-btn-danger,
.pw-layout button.pw-btn-danger {
  background: var(--pw-color-action-danger-bg);
  color: var(--pw-color-status-error-fg);
  border: 1px solid var(--pw-color-status-error-border);
}

.pw-layout a.pw-btn-danger:hover,
.pw-layout button.pw-btn-danger:hover {
  background: var(--pw-color-status-error-bg);
  color: var(--pw-color-status-error-fg);
  border-color: var(--pw-color-status-error-border);
}

/* Per-item processing actions — each has a distinct color to aid scanning.
   `.pw-layout button.` / `.pw-layout a.` make these (0,2,1): above the global
   BUTTONS rules, and tied with the button hover (0,2,1), which they follow in
   source order. */
.pw-layout a.pw-btn-attach-action,
.pw-layout button.pw-btn-attach-action {
  background: var(--pw-color-status-info-bg);
  color: var(--pw-color-status-info-fg);
  border: 1px solid var(--pw-color-status-info-border);
}

.pw-layout a.pw-btn-attach-action:hover,
.pw-layout button.pw-btn-attach-action:hover {
  background: var(--pw-color-status-info-bg-hover);
  color: var(--pw-color-status-info-fg);
  border-color: var(--pw-color-status-info-border);
}

.pw-layout a.pw-btn-create-action,
.pw-layout button.pw-btn-create-action {
  background: var(--pw-color-status-success-bg);
  color: var(--pw-color-status-success-fg);
  border: 1px solid var(--pw-color-status-success-border);
}

.pw-layout a.pw-btn-create-action:hover,
.pw-layout button.pw-btn-create-action:hover {
  background: var(--pw-color-status-success-bg-hover);
  color: var(--pw-color-status-success-fg);
  border-color: var(--pw-color-status-success-border);
}

.pw-layout a.pw-btn-skip-action,
.pw-layout button.pw-btn-skip-action {
  background: var(--pw-color-surface-sunken);
  color: var(--pw-color-text-muted);
  border: 1px solid var(--pw-color-border);
}

.pw-layout a.pw-btn-skip-action:hover,
.pw-layout button.pw-btn-skip-action:hover {
  background: var(--pw-color-surface-sunken-hover);
  color: var(--pw-color-text-muted);
  border-color: var(--pw-color-border);
}

/* Unmapped people list in pull show */
.pull-unmapped-list {
  list-style: disc;
  padding-left: var(--pw-space-6);
  margin: var(--pw-space-2) 0 var(--pw-space-4);
  font-size: var(--pw-text-base);
  color: var(--pw-color-text);
}

.pull-unmapped-list li {
  padding: var(--pw-space-1) 0;
}

/* Inline SVG icons within buttons */
.pw-icon {
  vertical-align: -0.125em;
  flex-shrink: 0;
}

/* ----------------------------------------
   AUTH PAGES
   Centered card layout for Devise sign-in, registration, password, etc.
---------------------------------------- */
.auth-page {
  max-width: 420px;
  margin-inline: auto;
}

.auth-page h2 {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.auth-page article {
  margin-top: 0;
}

.remember-me {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-block: 0.75rem;
}

.remember-me input[type="checkbox"] {
  margin-bottom: 0;
}

.remember-me label {
  margin-bottom: 0;
  font-weight: 400;
}

.field-hint {
  display: block;
  color: var(--pw-color-text-muted);
  margin-top: -0.5rem;
  margin-bottom: 0.75rem;
}

.auth-page input:disabled {
  opacity: 1;
  color: var(--pw-color-text-muted);
  background: var(--pw-color-surface-sunken);
  cursor: default;
}

.auth-errors {
  background: var(--pw-color-status-error-bg);
  color: var(--pw-color-status-error-fg);
  border: 1px solid var(--pw-color-status-error-border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.auth-errors ul {
  margin: 0;
  padding-left: 1.25rem;
}

.auth-errors li {
  margin-bottom: 0.15rem;
}

.auth-links {
  flex-direction: column;
  align-items: center;
  margin-top: 1.25rem;
}

body .auth-links a {
  color: var(--pw-color-text-muted);
  font-size: 0.875rem;
  margin-bottom: 0.35rem;
}

body .auth-links a:hover {
  color: var(--pw-color-link);
}

.danger-zone {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--pw-color-border);
}

.danger-zone h3 {
  color: var(--pw-color-status-error-fg);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}


/* ----------------------------------------
   DASHBOARD
---------------------------------------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.dashboard-grid article {
  margin: 0;
}

.dashboard-grid h2 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.dashboard-grid .empty-state {
  color: var(--pw-color-text-muted);
  font-size: 0.9rem;
}

.dashboard-grid .household-name {
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.dashboard-grid .household-members {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.9rem;
}

.text-muted {
  color: var(--pw-color-text-muted);
  margin-bottom: 0;
}


/* ----------------------------------------
   SIGN-IN LINK DISPLAY
---------------------------------------- */
.pw-sign-in-link-display {
  margin-bottom: var(--pw-space-4);
}

.pw-sign-in-link-display label {
  display: block;
  font-size: var(--pw-text-base);
  font-weight: var(--pw-weight-medium);
  color: var(--pw-color-text-muted);
  margin-bottom: var(--pw-space-1);
}


.pw-sign-in-link-expiry {
  font-size: var(--pw-text-sm);
  color: var(--pw-color-text-muted);
  margin-top: var(--pw-space-1);
}


/* ----------------------------------------
   WIZARD
   Guided multi-step setup flows (e.g., fundraiser setup)
---------------------------------------- */
.pw-wizard-intro {
  font-size: var(--pw-text-base);
  color: var(--pw-color-text-muted);
  line-height: var(--pw-leading-normal);
  margin-bottom: var(--pw-space-6);
  max-width: 42rem;
}

.pw-wizard-hint {
  font-size: var(--pw-text-sm);
  color: var(--pw-color-text-muted);
  line-height: var(--pw-leading-normal);
  margin-bottom: var(--pw-space-4);
}

/* Wizard step navigation (ADR 012): Back is an outline button on the left;
   the forward group on the right is the primary "Save and continue" (or
   "Continue" when nothing is pending), with "Skip for now" as a muted text
   link beside it. Wraps at narrow widths. */
.pw-wizard-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--pw-space-4);
  margin-top: var(--pw-space-6);
}

.pw-wizard-nav__forward {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--pw-space-4);
  margin-left: auto;
}

/* (0,2,1) to beat base.css's .pw-layout a (0,1,1). On hover it ties with
   .pw-layout a:hover and wins by loading later, so it stays muted and
   picks up that rule's underline. */
.pw-layout a.pw-wizard-nav__skip {
  font-size: var(--pw-text-base);
  color: var(--pw-color-text-muted);
}

/* Product card pattern for batch entry */
.pw-product-card {
  background: var(--pw-color-surface-sunken);
  border: 1px solid var(--pw-color-border);
  border-radius: var(--pw-radius-lg);
  padding: var(--pw-space-4);
  margin-bottom: var(--pw-space-4);
}

.pw-product-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--pw-space-3);
}

.pw-product-card__title {
  font-size: var(--pw-text-base);
  font-weight: var(--pw-weight-semibold);
  color: var(--pw-color-text);
}

.pw-product-card__remove {
  font-size: var(--pw-text-sm);
  color: var(--pw-color-status-error-fg);
  cursor: pointer;
}

/* Manager cards for wizard step 4 */
.pw-manager-cards {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pw-space-3);
  margin-bottom: var(--pw-space-6);
}

.pw-manager-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--pw-space-4);
  background: var(--pw-color-surface-sunken);
  border: 1px solid var(--pw-color-border);
  border-radius: var(--pw-radius-lg);
  padding: var(--pw-space-3) var(--pw-space-4);
  min-width: 200px;
  flex: 0 1 auto;
}

.pw-manager-card__content {
  flex: 1;
  min-width: 0;
}

.pw-manager-card__header {
  display: flex;
  align-items: center;
  gap: var(--pw-space-2);
}

.pw-manager-card__name {
  font-size: var(--pw-text-base);
  font-weight: var(--pw-weight-semibold);
  color: var(--pw-color-text);
}

.pw-manager-card__badge {
  font-size: var(--pw-text-xs);
  font-weight: var(--pw-weight-medium);
  color: var(--pw-color-status-success-fg);
  background: var(--pw-color-status-success-bg);
  border: 1px solid var(--pw-color-status-success-border);
  border-radius: var(--pw-radius-full);
  padding: 0.1rem 0.5rem;
}

.pw-manager-card__holders {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pw-space-1);
  margin-top: var(--pw-space-1);
}

.pw-manager-card__holder {
  font-size: var(--pw-text-sm);
  color: var(--pw-color-text-muted);
}

.pw-manager-card__holder + .pw-manager-card__holder::before {
  content: ", ";
}

.pw-manager-card__empty {
  font-size: var(--pw-text-sm);
  color: var(--pw-color-text-muted);
  font-style: italic;
  margin-top: var(--pw-space-1);
  display: block;
}

/* The inline remove action is a button_to <button> drawn as a red text
   link. (0,2,1) and hover (0,3,1) beat the global BUTTONS rules. */
.pw-layout button.pw-manager-card__remove {
  font-size: var(--pw-text-sm);
  color: var(--pw-color-status-error-fg);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
}

.pw-layout button.pw-manager-card__remove:hover {
  color: var(--pw-color-status-error-fg);
  background: var(--pw-color-status-error-bg);
  border: none;
}

/* Review step */
.pw-review-callout {
  background: var(--pw-color-status-warning-bg);
  border: 1px solid var(--pw-color-status-warning-border);
  border-radius: var(--pw-radius-md);
  padding: var(--pw-space-3) var(--pw-space-4);
  margin-bottom: var(--pw-space-4);
  font-size: var(--pw-text-base);
  color: var(--pw-color-text);
}

.pw-review-list {
  margin: var(--pw-space-2) 0 0 0;
  padding-left: var(--pw-space-5);
}

.pw-review-list li {
  margin-bottom: var(--pw-space-1);
  font-size: var(--pw-text-base);
}


/* ----------------------------------------
   FOOTER
---------------------------------------- */
body > footer {
  margin-top: 4rem;
  padding-block: 1.5rem;
  border-top: 1px solid var(--pw-color-border);
}

body > footer small {
  color: var(--pw-color-text-muted);
}
