.cart-screen {
  max-width: 760px;
  margin: 20px auto 60px;
  padding: 20px;
  background: var(--parchment);
  border: 1px solid var(--mist);
  border-radius: 10px;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  border-bottom: 2px solid #ccc;
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.sidebar-header .sidebar-header-actions {
  justify-content: flex-end;
}

.sidebar-header h2 {
  margin: 0;
  color: #333;
}

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Shape comes from the shared button rule in layout.css; only the colour here. */
.back-to-cards-btn {
  background-color: var(--shop-green);
  border-color: var(--shop-green);
  color: #fff;
}

.back-to-cards-btn:hover {
  background-color: #005c00;
  border-color: #005c00;
}

.close-btn {
  background: var(--shop-green);
  color: white;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-weight: bold;
  font-size: 1rem;
}

/* Shape and hover come from layout.css. */
.recalculate-cart-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* No display:none here: the element is rendered conditionally. */
.cart-stale-warning,
.cart-sent-banner {
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  line-height: 1.35;
}

.cart-stale-warning {
  background-color: #fff3cd;
  color: #664d03;
  border: 1px solid #ffe69c;
}

.cart-sent-banner {
  background-color: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.send-request-btn.already-sent {
  background: #fff;
  color: var(--shop-green);
  border: 2px solid var(--shop-green);
}

#cartList {
  list-style: none;
  padding: 0;
  margin: 0;
  flex-grow: 1;
  overflow-y: auto;
  color: #333;
}

.cart-item-body {
  flex-grow: 1;
  line-height: 1.3;
}

.cart-item-details {
  font-size: 0.95rem;
  color: #666;
}

/* Colours from .card-tags (style.css), dimensions matched to .condition-chip. */
.cart-item-details .card-tags,
.cart-item-details .condition-chip {
  display: inline-block;
  font-size: inherit;
  padding: 0 5px;
}

/* Transparent border equalises badge heights with the 2px gold foil border;
   :not(.foil) keeps the gold (same specificity, cart.css loads after style.css). */
.cart-item-details .card-tags:not(.foil),
.cart-item-details .condition-chip {
  border: 1px solid transparent;
}

.cart-item-price {
  white-space: nowrap;
  font-weight: bold;
  margin-left: 10px;
  font-size: 1.15rem;
  /* Fixed width so the quantity field does not shift with the amount. */
  min-width: 96px;
  text-align: right;
}

.cart-item-stale {
  cursor: help;
  font-size: 0.9rem;
}

#cartList li {
  padding: 10px 0;
  border-bottom: 1px solid #ddd;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.05rem;
}

.cart-item-note {
  width: 100%;
  max-width: 220px;
  margin-top: 4px;
  padding: 3px 6px;
  border: 1px solid #ddd;
  border-radius: 3px;
  font-size: 0.8rem;
  color: #333;
}

.cart-item-note:focus {
  border-color: var(--shop-green);
  outline: none;
}

.cart-item-note-btn {
  margin-left: 8px;
  padding: 0;
  background: none;
  border: none;
  color: var(--shop-green);
  cursor: pointer;
  font-size: 0.9rem;
  font-style: italic;
}

.cart-item-note-btn:hover {
  text-decoration: underline;
}

.cart-item-thumb {
  width: 56px;
  height: 78px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  margin-right: 10px;
  background-color: #ddd;
}

.cart-item-thumb-placeholder {
  border: 1px dashed #bbb;
}

.remove-btn {
  color: var(--shop-green);
  background: none;
  border: none;
  cursor: pointer;
  font-weight: bold;
  padding: 0 5px;
  font-size: 1.2rem;
}

.cart-summary {
  padding-bottom: 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid #ddd;
}

.sidebar-footer {
  border-top: 2px solid #ccc;
  padding-top: 15px;
  margin-top: 10px;
  color: #333;
}

.cart-offer-validity {
  margin: 6px 0 10px 0;
  text-align: center;
  font-size: 0.95rem;
  color: #555;
}

.cart-payout {
  display: flex;
  margin-bottom: 0;
  border: 1px solid #ccc;
  border-radius: 6px;
  overflow: hidden;
}

.cart-payout-btn {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px;
  background-color: #fff;
  border: none;
  color: #333;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: background-color 0.15s ease;
}

.cart-payout-btn + .cart-payout-btn {
  border-left: 1px solid #ccc;
}

.cart-payout-btn:hover {
  background-color: #f0f0f0;
}

.cart-payout-btn.active {
  background-color: var(--shop-green);
  color: #fff;
}

/* Under the three buttons: how much of the total the client wants in cash. */
.cart-payout-split {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.9rem;
}

.cart-payout-split input {
  width: 80px;
  padding: 4px 6px;
  text-align: right;
}

.cart-payout-label {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.cart-payout-amount {
  font-size: 1.35rem;
  letter-spacing: normal;
}

.cart-payout-bonus {
  font-size: 0.8rem;
  letter-spacing: normal;
  opacity: 0.75;
}

.cart-email-input {
  padding: 10px;
  width: 100%;
  border-radius: 4px;
  border: 1px solid #ccc;
  margin-bottom: 10px;
}

.send-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.send-actions .send-request-btn {
  margin-bottom: 0;
  flex: 1;
}

.send-request-btn {
  width: 100%;
  padding: 12px;
  font-weight: bold;
  border-radius: 4px;
  cursor: pointer;
  background: var(--shop-green);
  color: white;
  border: none;
  font-size: 1.1rem;
  margin-bottom: 10px;
}

.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.secondary-btn {
  flex: 1;
  min-width: 100px;
  padding: 10px;
  font-weight: bold;
  border-radius: 4px;
  cursor: pointer;
  background: #e8e8e8;
  color: #333;
  border: 1px solid #ccc;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.secondary-btn:hover {
  background: #ddd;
}

@media (max-width: 768px) {
  .cart-screen {
    padding: 12px;
  }
}

@media (max-width: 600px) {
  .sidebar-header {
    flex-direction: column;
    align-items: stretch;
  }
}

.print-only {
  display: none;
}

@media print {
  .fixed-header-wrapper,
  #results,
  .floating-help-btn,
  .floating-mass-btn,
  .floating-buyback-btn,
  .floating-cart-btn,
  .toast-container,
  .help-modal-overlay {
    display: none !important;
  }

  .cart-item-qty input {
    border: none;
    background: none;
    width: auto;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
  }

  body {
    background: #fff !important;
    /* Set inline by the fixed-header height sync; must be overridden for print. */
    padding-top: 0 !important;
  }

  .cart-screen {
    max-width: none;
    padding: 0;
  }

  .sidebar-header-actions,
  .remove-btn,
  .cart-stale-warning,
  .cart-sent-banner,
  .cart-email-input,
  .send-actions,
  .export-actions {
    display: none !important;
  }

  .print-only {
    display: block;
    font-size: 1rem;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 2px solid #333;
  }

  .cart-item-note {
    border: none;
    padding: 0;
  }

  .cart-item-note::placeholder {
    color: transparent;
  }

  #cartList {
    overflow: visible;
  }
}

.cart-counts {
  margin-left: 12px;
  font-size: 0.85rem;
  font-weight: normal;
  color: #666;
  white-space: nowrap;
}

@media (min-width: 980px) {
  .cart-screen {
    max-width: 1120px;
  }

  #cartList {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 28px;
  }

  /* Grid items otherwise size to their content instead of truncating. */
  #cartList li {
    min-width: 0;
  }

  .cart-item-body {
    min-width: 0;
  }
}

.cart-tabs {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  margin-bottom: 10px;
  border-bottom: 2px solid #ccc;
}

.cart-tab-list {
  display: flex;
  gap: 4px;
}

/* Kept off the bottom rule the tabs sit on. */
.cart-sort {
  margin: 0 0 6px auto;
}

.cart-tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  padding: 8px 14px;
  color: #666;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Four tabs fit a phone's width only with a narrower side padding. */
@media (max-width: 520px) {
  .cart-tab {
    padding: 8px 4px;
  }
}

.cart-tab:hover {
  color: #333;
}

.cart-tab.active {
  color: var(--shop-green);
  border-bottom-color: var(--shop-green);
}

.cart-tab-count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 10px;
  background: #ddd;
  color: #333;
  font-size: 0.75rem;
}

.cart-tab.active .cart-tab-count {
  background: var(--shop-green);
  color: #fff;
}

/* --app-header-height is measured at runtime (it varies with language and
   width). Opaque background required: the list scrolls under it. Desktop only:
   on mobile the header collapses on scroll to free space. */
@media (min-width: 769px) {
  .cart-sticky,
  .mass-sticky {
    position: sticky;
    top: var(--app-header-height, 0px);
    /* Above the tile badges (z-index 2, later in the DOM), below the fixed header
       (950) and modals (999+). */
    z-index: 100;
    background: var(--parchment);
    padding-top: 12px;
    margin-top: -12px;
  }
}

.cart-item-name-btn {
  padding: 0;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: bold;
  text-align: left;
}

.cart-item-name-btn:hover {
  color: var(--shop-green);
  text-decoration: underline;
}

.cart-item-thumb-clickable {
  cursor: pointer;
}

.cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
  padding: 40px 20px;
  text-align: center;
  color: #777;
}

.cart-empty-title {
  margin: 0;
  font-size: 1.1rem;
  color: #555;
}

.cart-empty .send-request-btn {
  width: auto;
  min-width: 220px;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
