/* Firmo design system (spec §15) — handwritten, no build step.
   Seller surfaces: calm, mobile-first, one decision per screen.
   Buyer/admin surfaces: denser market console with mono tables. */

:root {
  --canvas:  #F3F4F2;
  --paper:   #FFFFFF;
  --ink:     #17191C;
  --muted:   #626872;
  --line:    #D8DADD;
  --market:  #176B4D;
  --signal:  #B94724;
  --caution: #76590B;
  --danger:  #A83D3D;

  --font-ui: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "Consolas", "SFMono-Regular", monospace;
  --font-display: "Archivo Black", "Arial Black", "Helvetica Neue", sans-serif;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(23, 25, 28, 0.06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.5rem; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--market); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
strong { font-weight: 600; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 1rem; }
.wrap-seller { max-width: 660px; margin: 0 auto; padding: 0 1rem; }
.narrow-center { max-width: 560px; margin: 2rem auto; text-align: center; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }
.num { font-family: var(--font-mono); text-align: right; white-space: nowrap; }
.small { font-size: 0.85rem; }
.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;
}

/* Accessibility */
.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: var(--paper); padding: 0.5rem 1rem; z-index: 100;
}
.skip:focus { left: 0; }
:focus-visible { outline: 3px solid rgba(23, 107, 77, 0.5); outline-offset: 2px; border-radius: 4px; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 1rem; padding: 0.9rem 1.25rem;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.brand {
  font-family: var(--font-display); font-size: 1.15rem; color: var(--ink);
  letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.brand-dot { color: var(--market); }
.topnav { display: flex; flex-wrap: wrap; gap: 0.45rem; font-size: 0.95rem; }
.topnav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0.25rem 0.35rem;
  color: var(--ink); font-weight: 500; }
.topnav a:hover { color: var(--market); text-decoration: none; }

/* Hero (landing, §14.1) */
.hero { padding: 3.5rem 0 2rem; }
.hero-kicker { color: var(--market); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.8rem; }
.hero-title { font-family: var(--font-display); font-size: clamp(2.1rem, 5vw, 3.4rem); letter-spacing: -0.01em; margin: 0.4rem 0 0.8rem; }
.hero-sub { font-size: 1.15rem; color: var(--muted); max-width: 34rem; }
.cta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }

/* Buttons */
.btn {
  display: inline-block; border: 1px solid transparent; border-radius: 8px;
  min-height: 44px; padding: 0.7rem 1.2rem; font: inherit; font-weight: 600; cursor: pointer;
  text-align: center; background: var(--paper); color: var(--ink);
  border-color: var(--line);
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--signal); color: #fff; border-color: var(--signal); }
.btn-primary:hover { background: #96391C; border-color: #96391C; }
.btn-secondary { background: var(--paper); color: var(--market); border-color: var(--market); }
.btn-secondary:hover { background: rgba(23, 107, 77, 0.07); }
.btn-quiet { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.btn-block { display: block; width: 100%; }
.btn-lg { padding: 1rem 1.6rem; font-size: 1.1rem; }
.btn[disabled], .btn.is-disabled { opacity: 0.45; cursor: not-allowed; }
button.btn:not(.btn-block) { width: auto; }

/* Market strip (§14.1) */
.strip {
  width: 100%; border-collapse: collapse; font-family: var(--font-mono);
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.strip th, .strip td { padding: 0.7rem 0.9rem; text-align: left; border-bottom: 1px solid var(--line); }
.strip tr:last-child td { border-bottom: 0; }
.strip td { font-size: 0.92rem; white-space: nowrap; }
.strip .strip-name { font-weight: 600; }
.strip .strip-bid { color: var(--market); font-weight: 600; }
.strip-head { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

/* Panels & cards */
.panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem; margin: 1rem 0; box-shadow: var(--shadow);
}
.panel-tight { padding: 1rem; }
.section-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 1.6rem 0 0.5rem; }
/* minmax(0, 1fr) rather than 1fr: a bare 1fr track cannot shrink below its
   content's min-content width, so wide intrinsic controls (datetime-local)
   pushed the grid past its container. */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
/* Side by side only while each column stays readable; stacks otherwise. Used
   for datetime pairs, which clip their own value below ~13rem. */
.grid-fit { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1rem; }
.card-link {
  display: block; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.2rem; color: var(--ink);
}
.card-link:hover { border-color: var(--market); text-decoration: none; box-shadow: var(--shadow); }
.card-title { font-weight: 700; margin-bottom: 0.25rem; }

/* Stat cards (console) */
.stat {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.stat-value { font-family: var(--font-display); font-size: 1.5rem; }
.stat-value.market { color: var(--market); }
.stat-label { color: var(--muted); font-size: 0.82rem; }

/* Tables (console, mono prices) */
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th {
  text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); padding: 0.45rem 0.6rem; border-bottom: 2px solid var(--line);
}
.table td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table.mono td, .table .mono { font-family: var(--font-mono); }
.table-hover tr:hover td { background: rgba(23, 107, 77, 0.04); }

/* Chips */
.chip {
  display: inline-block; padding: 0.12rem 0.55rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; text-transform: capitalize;
  border: 1px solid transparent; white-space: nowrap;
}
.chip-market { background: rgba(23, 107, 77, 0.12); color: var(--market); border-color: rgba(23, 107, 77, 0.35); }
.chip-caution { background: rgba(184, 137, 18, 0.12); color: var(--caution); border-color: rgba(184, 137, 18, 0.4); }
.chip-danger { background: rgba(168, 61, 61, 0.1); color: var(--danger); border-color: rgba(168, 61, 61, 0.4); }
.chip-muted { background: rgba(98, 104, 114, 0.1); color: var(--muted); border-color: var(--line); }

/* Grade badge */
.grade { font-family: var(--font-mono); font-weight: 600; font-size: 0.8rem; padding: 0.1rem 0.45rem; border-radius: 5px; background: rgba(23, 107, 77, 0.1); color: var(--market); }
.grade-c, .grade-d { background: rgba(184, 137, 18, 0.12); color: var(--caution); }
.grade-parts { background: rgba(168, 61, 61, 0.12); color: var(--danger); }

/* Condition tag (§15.4 signature object) */
.tag-card {
  background: var(--ink); color: var(--paper); border-radius: 12px;
  padding: 1rem 1.2rem; font-family: var(--font-mono); text-transform: uppercase;
  letter-spacing: 0.04em; box-shadow: var(--shadow); max-width: 320px;
}
.tag-card p { margin: 0.12rem 0; }
.tag-lot { color: rgba(255, 255, 255, 0.6); font-size: 0.8rem; }
.tag-name { font-weight: 600; }
.tag-grade { color: rgba(255, 255, 255, 0.75); font-size: 0.85rem; }
.tag-price { font-size: 1.15rem; font-weight: 600; }
.tag-state { color: #7BD3AC; font-size: 0.8rem; font-weight: 600; }
.tag-state:not(.tag-state-funded) { color: rgba(255, 255, 255, 0.55); }

/* Offer panel (§14.2 signature screen) */
.offer-panel {
  background: var(--paper); border: 2px solid var(--market); border-radius: 14px;
  padding: 1.6rem; text-align: center;
}
.offer-kicker { text-transform: uppercase; letter-spacing: 0.1em; color: var(--market); font-weight: 700; font-size: 0.85rem; }
.big-price { font-family: var(--font-display); font-size: clamp(3rem, 9vw, 4.6rem); line-height: 1; margin: 0.4rem 0 0.8rem; }
.offer-lines { max-width: 340px; margin: 0 auto 0.9rem; text-align: left; }
.offer-lines .line { display: flex; justify-content: space-between; gap: 1rem; padding: 0.3rem 0; border-bottom: 1px dashed var(--line); }
.offer-lines .line:last-child { border-bottom: 0; }
.offer-lines .line dt { color: var(--muted); }
.offer-lines .line dd { margin: 0; font-weight: 600; font-family: var(--font-mono); text-align: right; }
.offer-assurances { color: var(--market); font-weight: 600; font-size: 0.9rem; }
.countdown { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.spread-note { color: var(--muted); font-size: 0.9rem; max-width: 36rem; margin: 0.8rem auto 0; }

/* Depth view */
.depth { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.depth-head { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.3rem; }

/* Rule block (buyer order preview, §6.2/§14.4) */
.rule-block {
  background: var(--ink); color: var(--paper); border-radius: 10px;
  padding: 0.9rem 1.1rem; font-family: var(--font-mono); font-size: 0.92rem;
  line-height: 1.7; text-transform: uppercase;
}
.rule-block .rule-dim { color: rgba(255, 255, 255, 0.55); }

/* Forms */
.field { margin-bottom: 1rem; }
.field label, .field legend { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.field .hint { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }
.input, input[type="text"], input[type="number"], input[type="datetime-local"],
input[type="email"], select, textarea {
  width: 100%; min-height: 44px; padding: 0.6rem 0.7rem; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; background: var(--paper); color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--market); outline: 2px solid rgba(23, 107, 77, 0.25); }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 0.8rem 1rem; margin: 0 0 1rem; }
.radio-row, .check-row { display: flex; flex-wrap: wrap; gap: 0.5rem 1.2rem; }
.radio-row label, .check-row label, .check-line { display: flex; align-items: center; gap: 0.4rem; min-height: 44px; font-weight: 400; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.2rem; flex-wrap: wrap; }
.form-actions .btn-block { flex: 1; }

/* Photos */
.photo-strip { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.item-photo { border-radius: 8px; border: 1px solid var(--line); width: 148px; height: 111px; object-fit: cover; background: var(--canvas); }
.photo-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.slot-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem; }
.slot-card .item-photo { width: 100%; height: auto; aspect-ratio: 4/3; margin: 0.5rem 0; }
.slot-label { font-weight: 600; }
.slot-help { color: var(--muted); font-size: 0.82rem; }
.slot-actions { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.5rem; }
.slot-actions .btn { font-size: 0.85rem; padding: 0.45rem 0.7rem; }
.slot-done { color: var(--market); font-weight: 600; font-size: 0.85rem; }

/* Flashes */
.flashes { margin-top: 1rem; }
.flash { padding: 0.7rem 1rem; border-radius: 8px; margin: 0 0 0.5rem; font-weight: 500; }
.flash-ok { background: rgba(23, 107, 77, 0.1); color: var(--market); border: 1px solid rgba(23, 107, 77, 0.35); }
.flash-error { background: rgba(168, 61, 61, 0.08); color: var(--danger); border: 1px solid rgba(168, 61, 61, 0.35); }

/* Timeline */
.timeline { display: flex; gap: 0; list-style: none; padding: 0; margin: 0.8rem 0; }
.timeline-step {
  flex: 1; text-align: center; font-size: 0.8rem; color: var(--muted);
  padding: 0.4rem 0.2rem; border-bottom: 3px solid var(--line);
}
.timeline-step.is-done { color: var(--market); border-color: var(--market); }
.timeline-step.is-current { font-weight: 700; color: var(--ink); border-color: var(--signal); }
.timeline-step.is-danger { color: var(--danger); border-color: var(--danger); }

/* Account chooser */
.account-list { list-style: none; padding: 0; display: grid; gap: 0.6rem; text-align: left; }
.account-card {
  width: 100%; display: block; text-align: left; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 1rem;
  min-height: 44px; cursor: pointer; font: inherit;
}
.account-card:hover { border-color: var(--market); }
.account-name { display: block; font-weight: 700; }
.account-meta { display: block; color: var(--muted); font-size: 0.85rem; }

/* Demo bar (§13.5) */
.demo-bar {
  position: relative; z-index: 10; background: var(--ink); color: var(--paper);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16); font-size: 0.85rem;
}
.demo-controls { max-width: 1080px; margin: 0 auto; }
.demo-controls > summary {
  display: flex; align-items: center; min-height: 44px;
  gap: 0.65rem; padding: 0.35rem 1rem;
  cursor: pointer; list-style: none;
}
.demo-controls > summary::-webkit-details-marker { display: none; }
.demo-summary-action {
  margin-left: auto; color: var(--paper); font-size: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.5); border-radius: 6px; padding: 0.2rem 0.55rem;
}
.demo-badge {
  background: var(--signal); color: #fff; font-weight: 700; font-size: 0.7rem;
  padding: 0.15rem 0.45rem; border-radius: 5px; letter-spacing: 0.08em;
}
.demo-current { font-weight: 600; }
.demo-role { color: rgba(255, 255, 255, 0.78); font-weight: 400; }
.demo-controls-body {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  padding: 0.2rem 1rem 0.8rem;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}
.demo-quick { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.demo-bar form { display: inline; margin: 0; }
.demo-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0.35rem 0.7rem;
  background: none; color: var(--paper); cursor: pointer; font: inherit; font-size: 0.82rem;
  border: 1px solid rgba(255, 255, 255, 0.5); border-radius: 6px;
}
.demo-link:hover { border-color: #fff; background: rgba(255, 255, 255, 0.08); text-decoration: none; }
.demo-link.is-active { background: rgba(255, 255, 255, 0.18); }
.demo-all { position: relative; }
.demo-all summary {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0.35rem 0.7rem;
  cursor: pointer; color: var(--paper); list-style: none;
  border: 1px solid rgba(255, 255, 255, 0.5); border-radius: 6px; font-size: 0.82rem;
}
.demo-all summary::-webkit-details-marker { display: none; }
.demo-all[open] { flex-basis: 100%; }
.demo-all[open] summary { margin-bottom: 0.4rem; }
.demo-all-list {
  max-height: 320px; overflow: auto;
  background: #25282D; border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 8px;
  padding: 0.5rem; display: grid; gap: 0.35rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.demo-launcher { margin-left: auto; }

/* Demo label (§6.1) */
.demo-label {
  display: inline-block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--caution); border: 1px solid rgba(118, 89, 11, 0.45);
  padding: 0.1rem 0.5rem; border-radius: 999px; background: rgba(118, 89, 11, 0.08);
}

/* Footer */
.footer { margin-top: 3rem; padding-top: 1rem; padding-bottom: 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; }

/* Wizard steps */
.steps { display: flex; gap: 0.4rem; list-style: none; padding: 0; margin: 1rem 0 1.4rem; flex-wrap: wrap; }
.steps li { font-size: 0.78rem; color: var(--muted); padding: 0.25rem 0.6rem; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); }
.steps li.is-current { color: var(--market); border-color: var(--market); font-weight: 700; }
.steps li.is-done { color: var(--ink); }

/* Assumptions list */
.assumptions { list-style: none; padding: 0; margin: 0; }
.assumptions li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.35rem 0; border-bottom: 1px dashed var(--line); }
.assumptions li:last-child { border-bottom: 0; }
.assumptions .a-q { color: var(--muted); }
.assumptions .a-a { font-weight: 600; text-transform: capitalize; font-family: var(--font-mono); }

/* Charts */
.chart-wrap { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.chart-wrap canvas { max-width: 100%; }
.chart-empty { min-height: 180px; display: grid; place-content: center; text-align: center; padding: 1rem; background: var(--canvas); border-radius: 8px; }
.chart-empty strong { color: var(--ink); }
.chart-wrap summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; }

/* Utility */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.text-right { text-align: right; }
.center { text-align: center; }
.flex { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.flex-between { display: flex; gap: 1rem; justify-content: space-between; align-items: baseline; flex-wrap: wrap; }
.grow { flex: 1; min-width: 240px; }

/* Responsive */
@media (max-width: 760px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .depth { grid-template-columns: 1fr; }
  .strip, .table {
    display: block; width: 100%; max-width: 100%; overflow-x: auto;
    overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch;
  }
  .strip td, .strip th { padding: 0.5rem; font-size: 0.8rem; white-space: nowrap; }
  .table th, .table td { white-space: nowrap; }
  .strip .hide-sm { display: none; }
  .hero { padding: 2rem 0 1.2rem; }
  .topbar { align-items: flex-start; padding: 0.65rem 0.75rem; }
  .brand { display: inline-flex; align-items: center; min-height: 44px; }
  .topnav {
    width: 100%; flex-wrap: nowrap; overflow-x: auto;
    gap: 0.15rem; font-size: 0.88rem;
    padding-bottom: 0.15rem; overscroll-behavior-inline: contain;
  }
  .topnav a { flex: 0 0 auto; padding: 0.25rem 0.45rem; }
  .panel { padding: 1rem; }
  .offer-panel { padding: 1.2rem 1rem; }
  .timeline { overflow-x: auto; }
  .timeline-step { min-width: 90px; }
  .demo-controls > summary { gap: 0.45rem; padding: 0.35rem 0.75rem; }
  .demo-summary-action { font-size: 0.75rem; }
  .demo-controls-body { align-items: stretch; padding: 0.2rem 0.75rem 0.75rem; }
  .demo-quick { display: grid; grid-template-columns: 1fr; width: 100%; }
  .demo-bar form { display: block; width: 100%; }
  .demo-link { width: 100%; }
  .demo-all, .demo-launcher { width: 100%; margin-left: 0; }
  .demo-all summary { width: 100%; }
  .demo-all-list { width: 100%; grid-template-columns: 1fr; }
  .demo-launcher { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
