/* ShrinkCheck — Design System */
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #242836;
  --surface-3: #2e3344;
  --border: #333848;
  --text: #e8eaf0;
  --text-2: #9ca3b4;
  --text-3: #6b7280;
  --accent: #f59e0b;
  --accent-2: #d97706;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --warn: #f59e0b;
  --warn-bg: rgba(245, 158, 11, 0.12);
  --good: #22c55e;
  --good-bg: rgba(34, 197, 94, 0.12);
  --blue: #3b82f6;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 80px;
  position: relative;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo { font-size: 24px; }

.header h1 {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-right {
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--surface-3);
  color: var(--text);
}

.badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Scanner */
.scanner-section {
  padding: 24px 20px;
}

.scanner-frame {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 32px;
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.scanner-viewfinder {
  width: 240px;
  height: 240px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.corner {
  position: absolute;
  width: 32px;
  height: 32px;
  border-color: var(--accent);
  border-style: solid;
  border-width: 0;
}

.corner.tl { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; border-radius: 4px 0 0 0; }
.corner.tr { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; border-radius: 0 4px 0 0; }
.corner.bl { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; border-radius: 0 0 0 4px; }
.corner.br { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; border-radius: 0 0 4px 0; }

.scan-line {
  position: absolute;
  width: 80%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scanMove 2.5s ease-in-out infinite;
  box-shadow: 0 0 12px var(--accent);
}

@keyframes scanMove {
  0%, 100% { top: 20%; }
  50% { top: 75%; }
}

.scanner-hint {
  color: var(--text-3);
  font-size: 13px;
  text-align: center;
}

.scanner-actions {
  display: flex;
  gap: 12px;
}

.btn-primary, .btn-secondary {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #000;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.3);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-3);
}

.full-width { width: 100%; }

/* Product Result */
.product-result { padding: 0 20px 24px; }

.product-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.product-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.product-image {
  font-size: 42px;
  width: 56px;
  text-align: center;
}

.product-info { flex: 1; }

.product-info h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

.product-brand {
  font-size: 13px;
  color: var(--text-2);
}

.product-upc {
  font-size: 11px;
  color: var(--text-3);
  font-family: 'SF Mono', Menlo, monospace;
}

.shrink-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  min-width: 64px;
}

.shrink-badge.alert {
  background: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.shrink-pct {
  font-size: 20px;
  font-weight: 800;
  color: var(--danger);
}

.shrink-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--danger);
  text-transform: uppercase;
}

/* Shrink Alert */
.shrink-alert {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  background: var(--danger-bg);
  border-bottom: 1px solid var(--border);
}

.alert-icon { font-size: 20px; }

.alert-text {
  font-size: 13px;
  color: var(--text);
}

.alert-text p {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 13px;
}

/* Timeline */
.timeline-section, .unit-price-section, .brand-section, .alternatives-section {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.timeline-section h3, .unit-price-section h3, .brand-section h3, .alternatives-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
}

.chart-area {
  height: 140px;
  display: flex;
  align-items: flex-end;
}

.chart-bars {
  display: flex;
  gap: 8px;
  width: 100%;
  height: 100%;
  align-items: flex-end;
}

.chart-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar {
  width: 100%;
  background: linear-gradient(180deg, var(--good), #16a34a);
  border-radius: 6px 6px 0 0;
  position: relative;
  min-height: 20px;
  transition: height 0.6s ease;
}

.chart-bar.shrunk {
  background: linear-gradient(180deg, var(--danger), #dc2626);
}

.chart-bar.current {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.3);
}

.bar-label {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.bar-year {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 6px;
}

/* Unit Price Cards */
.unit-price-cards {
  display: grid;
  grid-template-columns: 1fr auto 1fr 1fr;
  gap: 8px;
  align-items: center;
}

.unit-card {
  background: var(--surface-2);
  border-radius: var(--radius-xs);
  padding: 12px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.unit-card.arrow {
  background: none;
  font-size: 18px;
  color: var(--text-3);
  padding: 0;
}

.unit-card.increase {
  background: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.unit-label {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.unit-value {
  font-size: 16px;
  font-weight: 700;
}

.unit-value.bad { color: var(--danger); }

.unit-detail {
  font-size: 10px;
  color: var(--text-3);
}

/* Brand Card */
.brand-card {
  display: flex;
  gap: 20px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.brand-grade {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.grade-letter {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
}

.grade-letter.A { background: var(--good-bg); color: var(--good); }
.grade-letter.B { background: rgba(34, 197, 94, 0.08); color: #86efac; }
.grade-letter.C { background: var(--warn-bg); color: var(--warn); }
.grade-letter.D { background: var(--danger-bg); color: var(--danger); }
.grade-letter.F { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }

.grade-label {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
}

.brand-stats {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-2);
}

.stat-row .bad { color: var(--danger); font-weight: 600; }

/* Alternatives */
.alt-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alt-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: all 0.2s;
}

.alt-item.best {
  border-color: rgba(34, 197, 94, 0.3);
  background: var(--good-bg);
}

.alt-emoji { font-size: 24px; }

.alt-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.alt-info strong { font-size: 14px; }

.alt-detail {
  font-size: 12px;
  color: var(--text-2);
}

.alt-savings {
  font-size: 11px;
  color: var(--good);
  font-weight: 600;
}

.alt-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
}

.alt-badge.good { background: var(--good-bg); color: var(--good); }
.alt-badge.ok { background: var(--warn-bg); color: var(--warn); }

/* Product Actions */
.product-actions {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
}

.btn-watch, .btn-report, .btn-share {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
}

.btn-watch:hover { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.btn-report:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.btn-share:hover { background: rgba(59, 130, 246, 0.1); border-color: var(--blue); color: var(--blue); }

/* Feed */
.feed-section {
  padding: 0 20px 24px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.feed-filter {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  cursor: pointer;
}

.feed-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feed-item {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.feed-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 0;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
}

.feed-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.username {
  font-size: 13px;
  font-weight: 600;
}

.timestamp {
  font-size: 11px;
  color: var(--text-3);
}

.shrink-badge-sm {
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 800;
}

.shrink-badge-sm.alert {
  background: var(--danger-bg);
  color: var(--danger);
}

.shrink-badge-sm.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.feed-content {
  padding: 12px 16px 14px;
}

.feed-product {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.feed-emoji { font-size: 28px; }

.feed-product strong {
  font-size: 14px;
  display: block;
  margin-bottom: 4px;
}

.feed-product p {
  font-size: 13px;
  color: var(--text-2);
}

.feed-evidence {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.evidence-photo {
  flex: 1;
  background: var(--surface-2);
  border-radius: var(--radius-xs);
  padding: 20px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  border: 1px dashed var(--border);
}

.feed-actions {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--border);
  margin: 0 -16px -14px;
  padding: 0;
}

.feed-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-3);
  padding: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: color 0.2s;
}

.feed-btn:hover { color: var(--text); }

.feed-btn:not(:last-child) {
  border-right: 1px solid var(--border);
}

/* Trends */
.trends-section {
  padding: 0 20px 24px;
}

.trends-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.trend-cards {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.trend-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: transform 0.2s;
}

.trend-card:hover { transform: translateY(-2px); }

.trend-emoji { font-size: 28px; }

.trend-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.trend-pct {
  font-size: 13px;
  font-weight: 800;
}

.trend-pct.bad { color: var(--danger); }
.trend-pct.warn { color: var(--warn); }
.bad { color: var(--danger); }

/* Savings */
.savings-section {
  padding: 0 20px 24px;
}

.savings-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.savings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.savings-main {
  text-align: center;
  padding: 24px 20px;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), rgba(245, 158, 11, 0.08));
  border-bottom: 1px solid var(--border);
}

.savings-label {
  font-size: 13px;
  color: var(--text-2);
  display: block;
  margin-bottom: 8px;
}

.savings-value {
  font-size: 48px;
  font-weight: 800;
  color: var(--danger);
  display: block;
}

.savings-sub {
  font-size: 12px;
  color: var(--text-3);
  display: block;
  margin-top: 4px;
}

.savings-breakdown {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.savings-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-2);
}

.savings-row .bad { font-weight: 600; }

.savings-card .btn-primary {
  margin: 0 20px 20px;
  width: calc(100% - 40px);
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 0;
  z-index: 100;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 10px;
  cursor: pointer;
  transition: color 0.2s;
}

.nav-btn.active {
  color: var(--accent);
}

.nav-btn:hover {
  color: var(--text);
}

/* Utilities */
.hidden { display: none !important; }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.4s ease-out;
}

/* Responsive */
@media (max-width: 430px) {
  .app { max-width: 100%; }
}
