:root {
  --gold: #c89b1f;
  --gold-dark: #9c7915;
  --ink: #1a1a1a;
  --paper: #fafaf7;
  --muted: #6b6b6b;
  --line: #e2e0d8;
  --card: #ffffff;
  --danger: #b83232;
  --ok: #2b7a3e;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
}
.wrap { max-width: 920px; margin: 0 auto; padding: 0 20px; }

a { color: var(--gold-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 2.4rem; line-height: 1.15; margin: 0 0 0.6em; letter-spacing: -0.01em; }
h2 { font-size: 1.5rem; line-height: 1.25; margin: 1.8em 0 0.6em; }
h3 { font-size: 1.15rem; margin: 1.4em 0 0.4em; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.3em; }
li { margin-bottom: 0.4em; }
.muted { color: var(--muted); }

.site-header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; }
.brand {
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.brand::before {
  content: "◆ ";
  color: var(--gold);
}
.site-header nav a {
  margin-left: 18px;
  color: var(--muted);
  font-size: 0.95rem;
}
.site-header nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }

.hero {
  padding: 70px 0 40px;
  background: linear-gradient(180deg, #fff 0%, var(--paper) 100%);
}
.hero h1 { max-width: 720px; }
.hero .sub { font-size: 1.15rem; color: var(--muted); max-width: 660px; }
.hero-chat-cta { margin-top: 14px; font-size: 0.95rem; }

.btn-primary {
  display: inline-block;
  background: var(--gold);
  color: #1a1a1a;
  font-weight: 700;
  padding: 12px 22px;
  border-radius: 6px;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  font-size: 1rem;
}
.btn-primary:hover { background: var(--gold-dark); color: #fff; text-decoration: none; }
.btn-lg { font-size: 1.1rem; padding: 14px 26px; }

.how { padding: 40px 0; border-top: 1px solid var(--line); }
.steps { list-style: none; padding: 0; display: grid; gap: 14px; }
.steps li {
  background: var(--card);
  padding: 18px 20px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.steps li strong { color: var(--gold-dark); }

.form-section {
  padding: 50px 0;
  background: var(--card);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.listing-form { display: grid; gap: 14px; margin-top: 10px; }
.listing-form label {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}
.listing-form input[type="text"],
.listing-form input[type="tel"],
.listing-form input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  margin-top: 4px;
  border: 1px solid #cfcdc4;
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
}
.listing-form input:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  border-color: var(--gold);
}
.listing-form .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.listing-form .row .w-33 { grid-column: span 1; }
@media (max-width: 600px) {
  .listing-form .row { grid-template-columns: 1fr; }
}
.listing-form .opt { font-weight: 400; color: var(--muted); font-size: 0.85em; }

.consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #faf7eb;
  padding: 14px;
  border-radius: 6px;
  border: 1px solid #e6dfbf;
  font-weight: 400;
  font-size: 0.9rem;
  line-height: 1.5;
}
.consent input[type="checkbox"] { margin-top: 3px; }

.form-status { margin: 6px 0 0; font-size: 0.95rem; min-height: 1.3em; }
.form-status.ok { color: var(--ok); }
.form-status.err { color: var(--danger); }

.why { padding: 50px 0; }
.why-grid {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 10px;
}
@media (max-width: 600px) {
  .why-grid { grid-template-columns: 1fr; }
}
.why-grid li {
  background: var(--card);
  padding: 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.doc { padding: 50px 0 80px; }
.doc h2 { border-top: 1px solid var(--line); padding-top: 1.2em; }
.doc p, .doc ul { max-width: 720px; }

/* chat page — phone-style chat window */
.chat-section { padding: 32px 0 48px; }
.chat-wrap { max-width: 480px; padding: 0 16px; }
.chat-intro h1 { max-width: 640px; font-size: 1.9rem; }
.start-form { display: grid; gap: 14px; margin-top: 18px; }
.start-form input[type="text"] {
  width: 100%;
  padding: 11px 14px;
  margin-top: 4px;
  border: 1px solid #cfcdc4;
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
}
.start-form input[type="text"]:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  border-color: var(--gold);
}

.chat-panel {
  display: flex;
  flex-direction: column;
  height: min(78vh, 720px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.08);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gold);
  color: #1a1a1a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name { font-weight: 700; font-size: 0.98rem; line-height: 1.2; }
.chat-header-sub {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.2;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-link {
  background: none;
  border: 0;
  color: var(--gold-dark);
  cursor: pointer;
  font-size: 0.88rem;
  font-family: inherit;
  padding: 6px 8px;
}
.btn-link:hover { text-decoration: underline; }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #f7f5ef;
  scroll-behavior: smooth;
}

.bubble {
  max-width: 78%;
  padding: 9px 14px;
  border-radius: 18px;
  line-height: 1.42;
  font-size: 0.96rem;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.bubble-user {
  align-self: flex-end;
  background: var(--gold);
  color: #1a1a1a;
  border-bottom-right-radius: 6px;
}
.bubble-agent {
  align-self: flex-start;
  background: #ffffff;
  color: var(--ink);
  border-bottom-left-radius: 6px;
  border: 1px solid var(--line);
}
.bubble + .bubble { margin-top: 0; }
/* Tighter spacing when sequential bubbles come from the same sender */
.bubble-user + .bubble-user,
.bubble-agent + .bubble-agent { margin-top: -2px; }
.bubble-typing { opacity: 0.72; font-style: italic; font-size: 0.9rem; }

.chat-day-divider {
  align-self: center;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 14px 0 6px;
}
.chat-terminal {
  align-self: center;
  margin: 12px 0 4px;
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 86%;
  text-align: center;
}

.chat-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.chat-form textarea {
  flex: 1;
  padding: 9px 14px;
  border: 1px solid #cfcdc4;
  border-radius: 22px;
  font-family: inherit;
  font-size: 0.98rem;
  line-height: 1.35;
  resize: none;
  background: #fff;
  min-height: 40px;
  max-height: 140px;
  overflow-y: auto;
}
.chat-form textarea:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  border-color: var(--gold);
}
.chat-send {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--gold);
  color: #1a1a1a;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s ease, transform 0.08s ease;
}
.chat-send:hover:not(:disabled) { background: var(--gold-dark); color: #fff; }
.chat-send:active:not(:disabled) { transform: scale(0.95); }
.chat-send:disabled { background: #d8d5c6; color: #8a8676; cursor: default; }

.chat-footnote {
  font-size: 0.78rem;
  margin: 12px 16px 0;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 520px) {
  .chat-section { padding: 12px 0 24px; }
  .chat-wrap { padding: 0 10px; }
  .chat-panel {
    height: min(84vh, 820px);
    border-radius: 14px;
  }
}

/* Compact variant used inline on /resellers for buyer signup */
.reseller-join { padding: 50px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--card); }
.reseller-join .wrap { max-width: 560px; }
.chat-panel--compact {
  height: 440px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
  margin-top: 18px;
}
@media (max-width: 520px) {
  .chat-panel--compact { height: 60vh; max-height: 520px; }
}

/* Dashboard layout */
.dashboard { padding: 32px 0 60px; }
.dashboard .wrap { max-width: 960px; }
.section-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 10px;
}
.section-head h2 { margin: 0; }

.listings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 780px) {
  .listings-grid { grid-template-columns: 1fr 1fr; }
}
.listing-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.listing-top { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.listing-top h3 { margin: 0; font-size: 1.1rem; line-height: 1.25; }
.listing-price { font-weight: 700; color: var(--gold-dark); white-space: nowrap; }
.listing-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.meta-pill {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.82rem;
  padding: 3px 9px;
  border-radius: 999px;
}
.listing-notes {
  margin: 4px 0 0;
  font-size: 0.92rem;
  color: var(--muted);
  font-style: italic;
}
.listing-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 2px;
  font-size: 0.85rem;
}
.listing-actions .btn-primary { padding: 7px 14px; font-size: 0.9rem; }
.listing-actions .btn-primary:disabled {
  background: #d8d5c6;
  color: #8a8676;
  cursor: default;
}

.tier-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.1;
}
.tier-badge .tier-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  font-weight: 700;
}
.tier-badge .tier-price {
  font-size: 1.05rem;
  font-weight: 700;
}
.tier-badge .tier-timer,
.tier-badge .tier-slots {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  font-weight: 700;
}
.tier-exclusive {
  background: linear-gradient(135deg, #fff4d6, #f6e0a6);
  color: #6d4a00;
  border: 1px solid #ead58f;
}
.tier-exclusive--urgent {
  background: linear-gradient(135deg, #ffe0d6, #f7b49a);
  color: #7a2c10;
  border-color: #e58c6b;
  animation: tierPulse 1.4s ease-in-out infinite;
}
@keyframes tierPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(230, 124, 64, 0.0); }
  50%       { box-shadow: 0 0 0 4px rgba(230, 124, 64, 0.25); }
}
.tier-timer--expired { font-style: italic; font-weight: 400; }
.tier-timer--fresh { font-style: italic; font-weight: 500; opacity: 0.85; }
.tier-nonexclusive {
  background: #f1efe5;
  color: #3a3a3a;
  border: 1px solid var(--line);
}

/* Admin console */
.wrap-wide { max-width: 1180px; }
.admin { padding: 32px 0 60px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--ink); line-height: 1.1; }
.stat-label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 4px; }
.stat-sub { font-size: 0.75rem; color: var(--muted); margin-top: 6px; }
.stats-detail { margin: 0 0 10px; font-size: 0.85rem; color: var(--muted); }

.admin-tabs {
  display: flex;
  gap: 4px;
  margin: 22px 0 10px;
  border-bottom: 1px solid var(--line);
}
.tab-btn {
  background: none;
  border: 0;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active {
  color: var(--gold-dark);
  border-bottom-color: var(--gold);
  font-weight: 600;
}

.table-wrap { overflow-x: auto; }
#table-listings, #table-buyers, #table-sellers, #table-assignments, #table-sessions {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.table-wrap th,
.table-wrap td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.table-wrap th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--paper);
  position: sticky;
  top: 0;
}
.table-wrap td.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  color: var(--muted);
}
.table-wrap tbody tr:hover { background: var(--paper); }
.table-wrap tr.row-disputed {
  background: #fff3ee;
}
.table-wrap tr.row-disputed:hover { background: #ffe8df; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-dispute {
  background: #f7dad0;
  color: #8a2a0c;
  border: 1px solid #e58c6b;
}
.tiny-link {
  font-size: 0.75rem;
  color: var(--gold-dark);
  margin-left: 4px;
}

.return-overlay {
  position: fixed; inset: 0;
  background: rgba(26, 26, 26, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  padding: 20px;
}
.return-card {
  background: #fff;
  border-radius: 12px;
  padding: 22px 26px;
  max-width: 420px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
  font-size: 0.96rem;
  line-height: 1.45;
}
.return-card p { margin: 0; }

.listing-card--claimed {
  background: #faf7eb;
  border-color: #e6dfbf;
}
.listing-card--claimed h3::before {
  content: "✓ ";
  color: var(--ok);
  margin-right: 2px;
}
.seller-contact {
  border-top: 1px solid #e6dfbf;
  padding-top: 10px;
  margin-top: 2px;
  font-size: 0.95rem;
  line-height: 1.5;
}
.seller-contact strong {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.seller-contact a { color: var(--gold-dark); font-weight: 600; }
.seller-contact .small { font-size: 0.82rem; margin-top: 2px; }
.muted.small { font-size: 0.82rem; }

.filters-summary { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.filters-summary .chip {
  background: #faf7eb;
  border: 1px solid #e6dfbf;
  color: var(--ink);
  font-size: 0.85rem;
  padding: 4px 10px;
  border-radius: 999px;
}
.filters-summary .chip strong { font-weight: 600; color: var(--muted); margin-right: 4px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.02em; }

.filters-form { display: grid; gap: 12px; margin-top: 14px; }
.filters-form label { display: block; font-size: 0.95rem; font-weight: 600; }
.filters-form input[type="text"],
.filters-form input[type="number"],
.filters-form select {
  width: 100%;
  padding: 9px 12px;
  margin-top: 4px;
  border: 1px solid #cfcdc4;
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
}
.filters-form .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.filters-form .row .w-33 { grid-column: span 1; }
.filters-form .row .w-50 { grid-column: span 1; }
@media (max-width: 600px) {
  .filters-form .row { grid-template-columns: 1fr; }
}
.filters-form .row.row-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 600px) {
  .filters-form .row.row-3 { grid-template-columns: 1fr; }
}
.filters-form .opt { font-weight: 400; color: var(--muted); font-size: 0.82em; }
.filters-form .title-statuses {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}
.filters-form .title-statuses legend { padding: 0 6px; color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }
.filters-form .title-statuses label { font-weight: 400; font-size: 0.95rem; }
.filters-form .checkbox-label { font-weight: 400; display: flex; gap: 8px; align-items: center; margin-top: 18px; }
.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 4px;
}
.form-status.err { color: var(--danger); }
.form-status.ok  { color: var(--ok); }

.doc-section { margin-top: 2rem; }
.doc-section h2 { margin-top: 0; }
ul.kv { list-style: none; padding: 0; max-width: 620px; }
ul.kv li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
ul.kv li strong { color: var(--muted); font-weight: 600; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #f2efe4;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.92em;
}

#sign-out { margin-left: 18px; color: var(--muted); font-size: 0.95rem; }
#buyer-name { margin-right: 8px; font-size: 0.9rem; }

.site-footer {
  padding: 28px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  background: #fff;
}
.site-footer p { margin: 4px 0; }
