:root {
  --bg: #ffffff;
  --text: #1c1c1e;
  --hint: #8e8e93;
  --link: #2481cc;
  --button: #2481cc;
  --button-text: #ffffff;
  --secondary-bg: #f2f2f7;
  /* Darker red reads fine on a light card background; on dark backgrounds
     it loses contrast, so app.js swaps this to a brighter red based on
     Telegram.WebApp.colorScheme. */
  --red: #c0392b;
  --red-bg: #fdeceb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--secondary-bg);
  color: var(--text);
  padding-bottom: 24px;
}

#header {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 12px 16px;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

#progress-text {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}

#progress-bar {
  height: 6px;
  background: var(--secondary-bg);
  border-radius: 3px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  background: #34c759;
  width: 0%;
  transition: width 0.25s ease;
}

.group-header {
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  color: var(--hint);
  padding: 16px 16px 6px;
}

.item-wrapper {
  position: relative;
  margin: 6px 12px;
  border-radius: 12px;
}

.swipe-bg {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  background: transparent;
}

.swipe-bg-text {
  font-weight: 700;
  font-size: 15px;
  color: white;
  padding: 0 22px;
}

.swipe-bg.reveal-picked {
  background: #9CC54B;
  justify-content: flex-end;
}

.swipe-bg.reveal-not-picked {
  background: #e74c3c;
  justify-content: flex-start;
}

.item-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  padding: 10px;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  transition: opacity 0.15s ease;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.item-card.picked { opacity: 0.5; }

.item-card.urgent {
  background: var(--red-bg);
  border: 1px solid var(--red);
}

.item-photo {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--secondary-bg);
  flex-shrink: 0;
}

.item-info { flex: 1; min-width: 0; }

.item-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
}

.item-name .urgent-flag { color: var(--red); margin-right: 4px; }

.item-sub {
  font-size: 13px;
  color: var(--hint);
  margin-top: 2px;
}

.order-lines {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.order-line {
  font-size: 12.5px;
  color: var(--hint);
}

.order-line.urgent {
  color: var(--red);
  font-weight: 600;
}

.item-price {
  font-size: 13px;
  margin-top: 2px;
}

.item-price .old-price {
  text-decoration: line-through;
  color: var(--hint);
  margin-right: 4px;
}

.item-qty {
  font-weight: 700;
  color: var(--red);
  font-size: 14px;
  margin-right: 2px;
}

.shortfall-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: #ff9500;
  margin-top: 2px;
}

#error-banner {
  margin: 16px;
  padding: 12px;
  background: #ffe5e5;
  color: #b00020;
  border-radius: 8px;
  font-size: 14px;
}

#sheet-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
}

#sheet-root.open { display: block; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  padding: 16px;
  max-height: 80vh;
  overflow-y: auto;
  animation: sheet-up 0.18s ease;
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 12px;
  text-align: center;
}

.sheet-rows { display: flex; flex-direction: column; gap: 6px; }

.sheet-row {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 15px;
  text-align: left;
}

.sheet-row.danger { color: var(--red); }

.sheet-input {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--hint);
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 16px;
  margin-bottom: 10px;
}

.sheet-submit {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--button);
  color: var(--button-text);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}

.sheet-cancel {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--link);
  font-size: 15px;
}

.product-sheet { text-align: center; }

.product-photo {
  width: 60%;
  max-width: 220px;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 12px;
  margin: 4px auto 12px;
  display: block;
  background: var(--secondary-bg);
  transition: transform 0.2s ease;
}

.product-photo.zoomed {
  transform: scale(2.2);
  position: relative;
  z-index: 5;
}

.product-name {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
}

.product-meta {
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 4px;
}

.product-desc {
  font-size: 14px;
  color: var(--text);
  text-align: left;
  margin: 12px 0;
  line-height: 1.4;
}

.product-suppliers { text-align: left; margin-bottom: 12px; }
