/* W4 islands (plan 01): trade page, trade account tab, subscription box, account subscriptions, gift boxes and the
   lead forms' sent state. style.css tokens and components only (.btn, .field, .form-card, .topics). */

.w4-muted {
  color: var(--tx-2);
  font-size: 0.9rem;
}
.w4-empty {
  color: var(--tx-2);
  padding: 1rem 0;
}
.w4-error {
  color: var(--brick);
  font-weight: 700;
}
.w4-status,
.form-status {
  min-height: 1.4em;
  font-size: 0.88rem;
  color: var(--tx-2);
}
.w4-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 1rem;
}
[aria-busy="true"] {
  cursor: progress;
}
button[aria-busy="true"] {
  opacity: 0.7;
}

/* ---- lead forms: honeypot, consent, sent state */
.lead-hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.field-check {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  font-size: 0.85rem;
  color: var(--tx-2);
}
.field-check input {
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.2rem;
  accent-color: var(--maroon);
  flex: none;
}
.field-check a {
  color: var(--hd);
  text-decoration: underline;
}
.field.invalid .field-check {
  color: var(--brick);
}
.lead-done {
  display: grid;
  gap: 0.6rem;
  padding: 0.4rem 0;
  outline: none;
}
.lead-done-h {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.4rem, 1.2vw + 1rem, 1.9rem);
  color: var(--hd);
}
.lead-wa {
  color: var(--hd);
  font-weight: 700;
  text-decoration: underline;
}
fieldset.invalid > .err {
  display: block;
}

/* ---- trade page app */
.tr-app {
  display: grid;
  gap: 1.1rem;
}
.tr-h {
  outline: none;
}
.tr-apply {
  display: grid;
  gap: 1.1rem;
}
.tr-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.7rem;
}
.tr-stats li {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 0.9rem 1rem;
  display: grid;
  gap: 0.15rem;
  font-size: 0.82rem;
  color: var(--tx-2);
}
.tr-stats strong {
  font-family: var(--display);
  font-size: 1.25rem;
  color: var(--hd);
  text-transform: capitalize;
}

/* ---- address picker */
.w4-addr {
  border: 0;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.6rem;
}
.w4-addr legend {
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  padding: 0;
}
.w4-addr-list {
  display: grid;
  gap: 0.5rem;
}
.w4-addr-opt {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-2);
  cursor: pointer;
}
.w4-addr-opt:has(input:checked) {
  border-color: var(--maroon);
  box-shadow: 0 0 0 1px var(--maroon);
}
.w4-addr-opt input {
  margin-top: 0.3rem;
  accent-color: var(--maroon);
}
.w4-addr-opt span {
  display: grid;
  gap: 0.1rem;
  font-size: 0.9rem;
}
.w4-addr-new {
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
}
.w4-addr .err {
  font-size: 0.78rem;
  color: var(--brick);
  display: none;
}
.w4-addr-add {
  justify-self: start;
}

/* ---- price list grid and ledger */
.tp-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-2);
}
.tp-scroll:focus-visible {
  outline: 2px solid var(--flame);
}
.tp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 720px;
}
.tp-table th,
.tp-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.tp-table thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tx-2);
  background: var(--bg-3);
}
.tp-table tbody th {
  font-weight: 700;
  color: var(--hd);
}
.tp-table tr.tp-first td,
.tp-table tr.tp-first th {
  border-top: 2px solid var(--line);
}
.tp-num {
  text-align: right !important;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tp-num small {
  display: block;
  color: var(--tx-muted);
  font-size: 0.72rem;
}
.tp-qty {
  width: 5.5rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--bg);
}
.tp-qty[aria-invalid] {
  border-color: var(--brick);
}
.tp-err {
  display: block;
  color: var(--brick);
  font-size: 0.74rem;
  margin-top: 0.25rem;
}
.tp-stock.is-low {
  color: var(--maroon-2);
  font-weight: 700;
}
.tp-stock.is-out {
  color: var(--tx-muted);
}
.tp-foot {
  display: grid;
  gap: 0.5rem;
  margin-top: 1rem;
}
.tp-total {
  font-size: 1rem;
}
.tp-total-n {
  font-family: var(--display);
  font-size: 1.4rem;
  color: var(--hd);
  margin-left: 0.4rem;
}
.ta {
  display: grid;
  gap: 1rem;
}
.ta-h {
  font-size: 1.15rem;
  margin-top: 0.6rem;
}
.ta-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.35rem 1.2rem;
  font-size: 0.92rem;
}
.ta-facts dt {
  color: var(--tx-2);
}
.ta-facts dd {
  font-weight: 700;
  text-transform: none;
}
.ta-overdue {
  color: var(--brick);
  font-weight: 700;
}
.ta-ledger tr.is-overdue td {
  color: var(--brick);
}
.ta-balance {
  text-align: right;
}

/* ---- subscription box builder */
.sb-interval {
  margin-bottom: 1.2rem;
}
.sb-h {
  font-size: 1.15rem;
  margin: 0.4rem 0 0.8rem;
}
.sb-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.7rem;
}
.sb-item {
  display: grid;
  grid-template-columns: 56px 1fr;
  grid-template-areas: "img name" "img size" "img qty";
  gap: 0.35rem 0.8rem;
  align-items: center;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-2);
}
.sb-item img {
  grid-area: img;
  width: 56px;
  height: 56px;
  object-fit: contain;
}
.sb-name {
  grid-area: name;
  font-weight: 700;
  color: var(--hd);
}
.sb-item select,
.sb-item input,
.sm-editor select,
.sm-edit-line input {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--bg);
  font-size: 0.88rem;
}
.sb-item select {
  grid-area: size;
}
.sb-item input {
  grid-area: qty;
  width: 5rem;
}
.sb-summary {
  display: grid;
  gap: 0.8rem;
  margin-top: 1.4rem;
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-2);
}
.sb-count {
  font-weight: 700;
}
.sb-prices {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.3rem 1rem;
  font-variant-numeric: tabular-nums;
}
.sb-prices dd {
  text-align: right;
}
.sb-problem {
  color: var(--brick);
  font-weight: 700;
  min-height: 1em;
}
.sb-problem:empty {
  display: none;
}

/* ---- account: subscriptions */
.sm {
  display: grid;
  gap: 1rem;
}
.sm-card {
  display: grid;
  gap: 0.8rem;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-2);
}
.sm-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: baseline;
  flex-wrap: wrap;
}
.sm-title {
  font-size: 1.1rem;
}
.sm-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: var(--r-pill);
  background: var(--panel-2);
  color: var(--hd);
}
.sm-badge.is-active {
  background: var(--maroon);
  color: #fff;
}
.sm-badge.is-halted {
  background: var(--brick);
  color: #fff;
}
.sm-lines {
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
}
.sm-edit-line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}
.sm-edit-line input {
  width: 5rem;
}
.sm-editor {
  display: grid;
  gap: 0.9rem;
}
.sm-confirm {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  padding: 0.8rem;
  border-radius: var(--r-md);
  background: var(--panel-2);
}
.sm-confirm p {
  flex-basis: 100%;
  font-weight: 700;
}
.sm-past summary {
  cursor: pointer;
  color: var(--tx-2);
}
.sm-card.is-cancelled {
  opacity: 0.75;
}

/* ---- gifting: festival boxes */
.gift-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.gift-card {
  display: grid;
  gap: 0.5rem;
  align-content: start;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-2);
}
.gift-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
}
.gift-name {
  font-size: 1.1rem;
}
.gift-desc {
  font-size: 0.86rem;
  color: var(--tx-2);
}
.gift-price {
  font-weight: 700;
  color: var(--hd);
}
.gift-add {
  justify-self: start;
}
.gift-status {
  margin-top: 0.8rem;
}

@media (max-width: 640px) {
  .ta-facts {
    grid-template-columns: 1fr;
  }
  .ta-facts dd {
    margin-bottom: 0.4rem;
  }
}
