:root {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #f8fafc;
  --muted: #94a3b8;
  --blue: #3b82f6;
  --orange: #f97316;
  --purple: #a855f7;
  --border: #334155;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body.pwa-body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 16px calc(16px + env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 0 16px;
}
.app-header h1 { margin: 4px 0 0; font-size: 1.6rem; }
.eyebrow { margin: 0; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.icon-btn {
  width: 42px; height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 1.2rem;
}

.push-banner, .ios-hint {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  background: #172554;
  border: 1px solid #1d4ed8;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.push-banner button, .ios-hint button {
  border: 0;
  background: var(--blue);
  color: white;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 600;
  white-space: nowrap;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }
.status { margin: 8px 0 14px; font-size: 0.85rem; }

.tab-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.tab-btn {
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.55);
  color: var(--muted);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.92rem;
  font-weight: 700;
}

.tab-btn.active {
  background: var(--card);
  color: var(--text);
  border-color: #3b82f6;
}

.tab-panel.hidden {
  display: none;
}

.stats-header {
  margin-bottom: 12px;
}

.stats-eyebrow {
  margin: 0 0 4px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stats-total {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.1;
}

.stats-subline {
  margin: 6px 0 0;
  font-size: 0.82rem;
}

.stats-breakdown {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.stats-adjustments {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.stats-adjustment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.88rem;
}

.stats-adjustment-negative strong {
  color: #fca5a5;
}

.stats-row-negative strong {
  color: #fca5a5;
}

.stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stats-row.compact {
  padding: 4px 0;
}

.variation-stats-panel,
.stats-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 14px;
}

.variation-section-title {
  margin: 16px 0 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.variation-list {
  display: grid;
  gap: 10px;
}

.variation-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.45);
}

.variation-card img,
.variation-card .img-fallback {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
  background: #0b1220;
}

.variation-main {
  min-width: 0;
}

.variation-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.variation-id {
  font-size: 0.78rem;
  color: var(--muted);
}

.variation-name {
  margin: 6px 0;
  font-size: 0.92rem;
  line-height: 1.35;
}

.variation-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.variation-origin {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(51, 65, 85, 0.55);
}

.variation-origin-title {
  margin: 0 0 6px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.variation-marketplaces {
  display: grid;
  gap: 4px;
}

.variation-empty {
  margin: 0;
  font-size: 0.82rem;
}

.stats-row-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 0.88rem;
}

.stats-count {
  font-size: 0.75rem;
}

.section-title {
  margin: 18px 0 10px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.order-group {
  margin-bottom: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.order-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  column-gap: 12px;
  padding: 12px;
}

.order-card > img,
.order-card .img-fallback {
  width: 72px;
  height: 72px;
  grid-column: 1;
  grid-row: 1;
  border-radius: 12px;
  object-fit: cover;
  background: #0b1220;
}

.order-main {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}

.order-positions {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.order-position {
  display: grid;
  grid-template-columns: 72px 1fr;
  column-gap: 12px;
  align-items: center;
  padding: 10px 12px 10px 20px;
  border-top: 1px solid rgba(51, 65, 85, 0.55);
}

.position-copy {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.color-badge {
  display: inline-flex;
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.18);
  color: #bfdbfe;
}

.order-position:first-child {
  border-top: 0;
}

.order-position img,
.order-position .position-fallback {
  width: 48px;
  height: 48px;
  justify-self: center;
  border-radius: 8px;
  object-fit: cover;
  background: #0b1220;
}

.position-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1rem;
}

.position-name {
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--text);
  min-width: 0;
}

.position-count {
  font-size: 0.72rem;
  color: var(--muted);
}

.img-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1.4rem;
}

.order-top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.order-top-end {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.order-price {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.order-number { font-weight: 700; font-size: 1rem; }
.product-name { color: var(--text); font-size: 0.95rem; font-weight: 600; margin: 6px 0; line-height: 1.35; }
.external-ref { display: block; margin-top: 6px; font-size: 0.75rem; color: var(--muted); }
.order-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.72rem; font-weight: 700;
  padding: 4px 8px; border-radius: 999px;
}
.badge-auftrag { background: rgba(59,130,246,.2); color: #93c5fd; }
.badge-gewaehrleistung { background: rgba(249,115,22,.2); color: #fdba74; }
.badge-retoure { background: rgba(168,85,247,.2); color: #d8b4fe; }

.market-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.72rem; color: var(--muted);
}
.market-icon {
  width: 18px; height: 18px; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.62rem; font-weight: 800; color: white;
}
.market-amazon { background: #ff9900; }
.market-ebay { background: #e53238; }
.market-otto { background: #d4021d; }
.market-kaufland { background: #e65100; }
.market-galaxus { background: #0064ba; }
.market-shop { background: #16a34a; }
.market-unknown { background: #64748b; }

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
}

.login-body { display: grid; place-items: center; }
.login-card {
  width: min(100%, 360px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 22px;
  text-align: center;
}
.login-icon { font-size: 2.4rem; margin-bottom: 8px; }
.login-form { display: grid; gap: 10px; margin-top: 16px; }
.login-form input {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  font-size: 1rem;
}
.login-form button {
  padding: 14px;
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  color: white;
  font-weight: 700;
  font-size: 1rem;
}
.error { color: #fca5a5; }
