/* Resets + layout primitives. Brand tokens come from brand.css. */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.55;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 var(--space-4) 0;
  letter-spacing: -0.01em;
}
h1 { font-size: var(--text-h1); }
h2 { font-size: var(--text-h2); }
h3 { font-size: var(--text-h3); }

p { margin: 0 0 var(--space-4) 0; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
a:hover { color: var(--accent-hover); }

small, .small { font-size: var(--text-small); }
.micro { font-size: var(--text-micro); color: var(--fg-muted); }
.muted { color: var(--fg-muted); }

/* Layout */
.page { min-height: 100vh; display: flex; flex-direction: column; }
.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--space-5);
}
.container-narrow { max-width: 640px; }

/* Brand header */
.brand-header {
  padding: var(--space-5) 0;
}
.brand-header.theme-light { background: var(--bg); }
.brand-header.theme-dark  { background: var(--bg-accent); }
.brand-header img { display: block; height: 32px; width: auto; }

/* Hero strip — merchant-facing pages */
.hero {
  background: var(--bg-accent);
  color: var(--fg-on-accent);
  padding: var(--space-6) 0 var(--space-7);
}
.hero-gradient { background: var(--fw-ocean); }
.hero .container { display: flex; flex-direction: column; gap: var(--space-3); }
.hero h1, .hero h2 {
  color: var(--fg-on-accent);
  font-size: var(--text-display);
  margin: 0;
}
.hero .eyebrow {
  font-size: var(--text-small);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.9;
}

/* Card */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
  margin: calc(-1 * var(--space-6)) auto var(--space-6);
  position: relative;
  z-index: 1;
}
.card-plain {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field.field-full { grid-column: 1 / -1; }
.field label {
  font-size: var(--text-small);
  font-weight: 500;
  color: var(--fg);
}
.field input,
.field select,
.field textarea {
  font-family: var(--font-body);
  font-size: var(--text-body);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--fg);
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.field .help {
  font-size: var(--text-small);
  color: var(--fg-muted);
}
.field .error {
  font-size: var(--text-small);
  color: #B42318;
}

fieldset {
  border: 0;
  margin: 0 0 var(--space-6) 0;
  padding: 0;
}
legend {
  font-family: var(--font-display);
  font-size: var(--text-h3);
  font-weight: 700;
  margin-bottom: var(--space-4);
  padding: 0;
}

/* Buttons */
.btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-body);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.btn-primary {
  background: var(--accent);
  color: var(--fg-on-accent);
}
.btn-primary:hover { background: var(--accent-hover); color: var(--fg-on-accent); }
.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--fg);
}
.btn-outline:hover { border-color: var(--fg); color: var(--fg); }
.btn-link {
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  padding-left: 0;
  padding-right: 0;
  min-height: 0;
}
.btn-block { display: flex; width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }
@media (max-width: 480px) {
  .btn-row .btn { flex: 1 1 100%; }
}

/* Offer detail rows */
.detail-list { display: grid; grid-template-columns: 1fr; gap: var(--space-3); margin: var(--space-5) 0; }
.detail {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.detail:last-child { border-bottom: 0; }
.detail dt { color: var(--fg-muted); font-size: var(--text-small); margin: 0; }
.detail dd { margin: 0; font-weight: 500; text-align: right; }

/* Agent block (revealed on Speak to an Agent) */
.agent-block {
  background: var(--bg);
  border: 1px solid var(--fg-muted);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-top: var(--space-4);
  color: var(--fg-muted);
}
.agent-block strong { font-size: var(--text-h3); color: var(--fg); }
[hidden] { display: none !important; }

/* Status chips */
.chip {
  display: inline-block;
  font-size: var(--text-micro);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  background: var(--bg-muted);
  color: var(--fg-muted);
}
.chip-success { background: var(--success-bg); color: var(--success); }

/* Confirmation page success icon */
.success-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--success-bg);
  color: var(--success);
  font-size: 32px;
  margin-bottom: var(--space-4);
}

/* Footer */
footer.site-footer {
  margin-top: auto;
  padding: var(--space-6) 0;
  text-align: center;
  font-size: var(--text-small);
  color: var(--fg-muted);
}

/* ============================================================ */
/* MP2 sidebar + offer-card pattern (merchant-facing pages only) */
/* ============================================================ */

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}
.app-shell-sidebar {
  background: var(--fw-page-sidebar);
  padding: var(--space-6) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}
.app-shell-sidebar .brand {
  display: block;
}
.app-shell-sidebar .brand img {
  height: 28px;
  width: auto;
  display: block;
}
.app-shell-sidebar .sidebar-status {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.app-shell-sidebar .sidebar-status-label {
  font-size: var(--text-micro);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}
.app-shell-sidebar .sidebar-status-value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-body);
  color: var(--fg);
}
.app-shell-sidebar .sidebar-trust {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  font-size: var(--text-small);
  color: var(--fg-muted);
}
.app-shell-sidebar .sidebar-trust .trust-line {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  line-height: 1.4;
}
.app-shell-sidebar .sidebar-trust .trust-line svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.app-shell-main {
  background: var(--bg);
  padding: var(--space-6) var(--space-7) var(--space-7);
  display: flex;
  flex-direction: column;
}
.app-shell-main-head {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-small);
  color: var(--fg-muted);
  margin-bottom: var(--space-5);
}

@media (max-width: 720px) {
  /* On mobile the shell becomes a vertical stack. Drop the full-viewport
     min-height — it stretches the auto-sized sidebar row to fill the page,
     leaving a giant empty light-blue band under the status pill. */
  .app-shell {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .app-shell-sidebar {
    padding: var(--space-4) var(--space-5);
    gap: var(--space-3);
  }
  .app-shell-sidebar .sidebar-trust { display: none; }
  .app-shell-main { padding: var(--space-5) var(--space-4) var(--space-6); }
}

/* Heading just above the card */
.offer-head {
  margin-bottom: var(--space-5);
}
.offer-head h1 {
  margin: 0 0 var(--space-2) 0;
  font-size: clamp(1.5rem, 2.2vw + .6rem, 2rem);
}
.offer-head p {
  margin: 0;
  color: var(--fg-muted);
  max-width: 56ch;
}

/* The offer card itself */
.offer-card {
  background: var(--fw-page-card);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-5);
  position: relative;
}
.offer-card-status {
  position: absolute;
  top: -10px;
  left: var(--space-5);
}
.offer-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-5);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid rgba(0, 20, 40, 0.08);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.offer-lender {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.offer-lender-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.offer-lender-mark img {
  width: 24px;
  height: 24px;
  display: block;
}
.offer-lender-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-h3);
  color: var(--fg);
}
.offer-headline {
  text-align: right;
}
.offer-headline-label {
  font-size: var(--text-small);
  color: var(--fg-muted);
  margin-bottom: var(--space-1);
}
.offer-headline-value {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3.5vw + .5rem, 2.75rem);
  font-weight: 700;
  color: var(--fg);
  line-height: 1.05;
  letter-spacing: -0.01em;
}

/* Stats grid below the head; flexes 1 → 2 → 4 columns by width */
.offer-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-5);
}
.offer-stat {
  min-width: 0;
}
.offer-stat-label {
  font-size: var(--text-small);
  color: var(--fg-muted);
  margin: 0 0 var(--space-1) 0;
}
.offer-stat-value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-h3);
  color: var(--fg);
  margin: 0;
  overflow-wrap: break-word;
}

/* Status chips */
.status-chip {
  display: inline-block;
  font-size: var(--text-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 4px 10px;
  border-radius: 4px;
}
.status-chip-sent     { background: #DDE7FE; color: var(--fw-dark-blue); }
.status-chip-viewed   { background: var(--fw-light-gray); color: var(--fg-muted); }
.status-chip-expiring { background: var(--chip-expiring-bg); color: var(--chip-expiring-fg); }
.status-chip-accepted { background: var(--chip-accepted-bg); color: var(--chip-accepted-fg); }
.status-chip-declined { background: var(--chip-declined-bg); color: var(--chip-declined-fg); }

/* Action row below the card */
.offer-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  justify-content: flex-end;
}
.offer-actions .btn { border-radius: 999px; min-width: 140px; }
.offer-actions .btn-primary { padding-left: var(--space-6); padding-right: var(--space-6); }
@media (max-width: 480px) {
  .offer-actions { flex-direction: column-reverse; align-items: stretch; }
  .offer-actions .btn { width: 100%; }
}

/* "Speak to an agent" reveal block */
.agent-block-mp2 {
  margin-top: var(--space-5);
  padding: var(--space-4) var(--space-5);
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: var(--text-small);
}
.agent-block-mp2 strong { display: block; font-size: var(--text-h3); color: var(--fg); margin-top: 4px; }

/* "You're all set" celebration page */
.all-set-emoji {
  font-size: 1.8rem;
  display: inline-block;
  margin-left: var(--space-2);
}
.followup-text {
  color: var(--fg-muted);
  margin: var(--space-5) 0 var(--space-4);
}

/* ============================================================ */
/* Internal pages — sidebar nav, list table, form, filter chips */
/* ============================================================ */

/* Internal sidebar variations on the merchant shell. */
.internal-sidebar .sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius);
  color: var(--fg);
  font-family: var(--font-display);
  font-weight: 500;
  text-decoration: none;
  transition: background-color 100ms ease;
}
.sidebar-nav-item:hover { background: rgba(0, 67, 242, 0.06); color: var(--fg); }
.sidebar-nav-item.is-active {
  background: var(--accent);
  color: var(--fg-on-accent);
}
.sidebar-nav-item.is-active:hover { background: var(--accent-hover); color: var(--fg-on-accent); }
.sidebar-nav-item svg { flex-shrink: 0; }

.sidebar-internal-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  font-size: var(--text-small);
  color: var(--fg-muted);
}
.sidebar-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.sidebar-link:hover { color: var(--accent-hover); }
.sidebar-user-label { font-size: var(--text-micro); text-transform: uppercase; letter-spacing: 0.08em; }
.sidebar-user-email { color: var(--fg); font-weight: 500; margin-bottom: var(--space-1); word-break: break-all; }

@media (max-width: 720px) {
  .internal-sidebar .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .internal-sidebar .sidebar-nav-item { flex: 1 1 auto; justify-content: center; padding: var(--space-2) var(--space-3); }
  .sidebar-internal-footer { display: none; }
}

/* Internal page heads */
.internal-page-head {
  margin-bottom: var(--space-5);
}
.internal-page-head .head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}
.internal-page-head h1 {
  margin: 0;
  font-size: clamp(1.5rem, 2vw + .6rem, 2rem);
}
.internal-page-head p { margin: 0; color: var(--fg-muted); }

/* Form sections (replaces card-plain wrapping for internal form) */
.form-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}
.form-section h2 {
  font-size: var(--text-h3);
  margin: 0 0 var(--space-4) 0;
}
.form-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  margin-top: var(--space-5);
  flex-wrap: wrap;
}
@media (max-width: 480px) {
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
}

/* Filter chips */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: var(--text-small);
  font-weight: 500;
  text-decoration: none;
  transition: background-color 100ms ease, color 100ms ease, border-color 100ms ease;
}
.filter-chip:hover { color: var(--fg); border-color: var(--fg-muted); }
.filter-chip.is-active {
  background: var(--accent);
  color: var(--fg-on-accent);
  border-color: var(--accent);
}
.filter-chip-count {
  font-size: var(--text-micro);
  background: rgba(0, 0, 0, 0.08);
  padding: 1px 6px;
  border-radius: 999px;
}
.filter-chip.is-active .filter-chip-count {
  background: rgba(255, 255, 255, 0.25);
}

/* Banner */
.banner {
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius);
  margin-bottom: var(--space-5);
  font-size: var(--text-body);
}
.banner-success {
  background: var(--success-bg);
  color: var(--success);
}

/* Empty state */
.empty-state {
  padding: var(--space-7) var(--space-5);
  text-align: center;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
}
.empty-state p { color: var(--fg-muted); margin-bottom: var(--space-5); }

/* Offers table (desktop) */
.offers-table-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.offers-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-small);
}
.offers-table th,
.offers-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
.offers-table thead th {
  background: var(--bg-card);
  color: var(--fg-muted);
  font-weight: 600;
  font-size: var(--text-micro);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.offers-table tbody tr:last-child td { border-bottom: 0; }
.offers-table tbody tr:hover { background: var(--bg-card); }
.cell-strong { font-weight: 600; color: var(--fg); }
.cell-muted  { color: var(--fg-muted); font-size: var(--text-small); }
.th-amount   { text-align: right; }
.td-amount   { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.th-actions  { width: 1%; white-space: nowrap; }
.td-actions  { white-space: nowrap; }

.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--fg-muted);
  text-decoration: none;
}
.sort-link:hover { color: var(--fg); }
.sort-link.is-active { color: var(--accent); }

.action-link {
  background: none;
  border: 0;
  padding: 0 var(--space-2);
  font: inherit;
  font-size: var(--text-small);
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.action-link:hover { color: var(--accent-hover); }
.action-link + .action-link { border-left: 1px solid var(--border); }

/* Mobile card list (replaces the table on narrow widths) */
.offers-cards { list-style: none; padding: 0; margin: 0; display: none; }
.offer-row-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.offer-row-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
}
.offer-row-amount {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-h3);
  color: var(--fg);
}
.offer-row-meta { color: var(--fg-muted); font-size: var(--text-small); }
.offer-row-actions {
  display: flex;
  gap: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
  margin-top: var(--space-2);
}

@media (max-width: 720px) {
  .offers-table-wrap { display: none; }
  .offers-cards { display: block; }
}

/* Internal sent state */
.copy-row {
  display: flex;
  gap: var(--space-3);
  align-items: stretch;
  margin: var(--space-4) 0;
}
.copy-row input {
  flex: 1;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: var(--text-small);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--fg);
}
