:root {
  --bg: #0f1420;
  --surface: #171e2e;
  --surface-2: #1e2740;
  --border: #2a3450;
  --text: #e8ecf5;
  --muted: #93a0bd;
  --mytek: #e8443c;
  --tun: #2f7fe8;
  --space: #b07cff;
  --green: #23c483;
  --red: #ff6b6b;
  --yellow: #f5c451;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

.site-header {
  background: linear-gradient(135deg, #131a2b, #0f1420 60%);
  border-bottom: 1px solid var(--border);
  padding: 34px 0 26px;
  text-align: center;
}

.site-header h1 { margin: 0; font-size: 2rem; letter-spacing: -0.5px; }

.site-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.8px;
  color: transparent;
  -webkit-text-fill-color: transparent;
  background: linear-gradient(95deg, #ff8a84, #f5c451 38%, #23c483 72%, #7db4ff);
  -webkit-background-clip: text;
  background-clip: text;
}
.site-brand .brand-mark { width: 34px; height: 34px; color: #23c483; flex: none; }

.vs-line { margin: 12px 0 0; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.3px; }

.brand.mytek { color: var(--mytek); }
.brand.tunisianet { color: var(--tun); }
.brand.spacenet { color: var(--space); }
.vs { color: var(--muted); font-weight: 400; font-size: 1.3rem; margin: 0 8px; }
.subtitle { color: var(--muted); margin: 8px 0 0; font-size: 0.95rem; }

.last-update { color: var(--muted); margin: 6px 0 0; font-size: 0.88rem; }
.last-update .lu-mytek { color: var(--mytek); }
.last-update .lu-tunisianet { color: var(--tun); }
.last-update .lu-spacenet { color: var(--space); }
.last-update .lu b { font-weight: 700; }
.last-update .lu-sep { color: var(--border); margin: 0 7px; }

main { padding: 28px 20px 60px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}

.stat-value { font-size: 1.7rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 0.85rem; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.6px; }

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.controls input[type="search"] {
  flex: 1 1 260px;
}

.controls input, .controls select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.95rem;
  outline: none;
}

.controls input:focus, .controls select:focus { border-color: var(--tun); }

h2 {
  font-size: 1.15rem;
  margin: 30px 0 14px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

h2 .count { color: var(--text); font-weight: 400; text-transform: none; font-size: 0.9rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }

.cmp-table { width: 100%; border-collapse: collapse; background: var(--surface); table-layout: fixed; }

.cmp-table th, .cmp-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }

.cmp-table th:nth-child(1), .cmp-table td:nth-child(1) { width: 36%; }
.cmp-table th:nth-child(2), .cmp-table td:nth-child(2) { width: 14%; }
.cmp-table th:nth-child(3), .cmp-table td:nth-child(3) { width: 15%; }
.cmp-table th:nth-child(4), .cmp-table td:nth-child(4) { width: 14%; }
.cmp-table th:nth-child(5), .cmp-table td:nth-child(5) { width: 21%; }

.cmp-table thead th {
  background: var(--surface-2);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  position: sticky;
  top: 0;
}

.cmp-table tbody tr:last-child td { border-bottom: none; }
.cmp-table tbody tr:hover { background: var(--surface-2); }
.cmp-table .num { text-align: right; white-space: nowrap; }

.prod-cell { display: flex; gap: 12px; align-items: center; min-width: 260px; }
.prod-cell > div { flex: 1 1 auto; min-width: 0; }

.prod-thumb {
  width: 54px; height: 54px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 4px;
  flex-shrink: 0;
}

.prod-name { font-weight: 600; font-size: 0.92rem; overflow-wrap: anywhere; }
.prod-name a { color: var(--text); text-decoration: none; }
.prod-name a:hover { text-decoration: underline; }
.prod-sub { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--muted); font-size: 0.78rem; margin-top: 3px; }
.sub-link { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); text-decoration: none; min-width: 0; max-width: 100%; }
.sub-link .sub-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-link:hover .sub-name { text-decoration: underline; }
.sub-link:hover .store-badge { filter: brightness(1.12); }

/* store badges — show which site sells this product */
.store-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px 2px 4px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.3px;
  white-space: nowrap;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, .14);
}
.store-badge img {
  width: auto;
  height: 14px;
  max-width: 58px;
  object-fit: contain;
  background: #fff;
  border-radius: 4px;
  padding: 1.5px 3px;
  flex-shrink: 0;
}
a.store-badge:hover { filter: brightness(1.12); }
.store-badge.sb-mytek { background: #e8443c; color: #fff; }
.store-badge.sb-tunisianet { background: #ffd400; color: #161616; border-color: rgba(0, 0, 0, .18); }
.store-badge.sb-spacenet { background: #ff6600; color: #fff; }

.store-badge.sb-sm { font-size: 0.64rem; padding: 1px 7px 1px 3px; gap: 4px; }
.store-badge.sb-sm img { height: 11px; max-width: 44px; padding: 1px 2px; border-radius: 3px; }
.store-badge.sb-cell { font-size: 0.68rem; padding: 1px 8px 1px 3px; }
.store-badge.sb-cell img { height: 13px; max-width: 52px; }
.store-badge.sb-lg { font-size: 0.82rem; padding: 5px 13px 5px 6px; gap: 7px; }
.store-badge.sb-lg img { height: 17px; max-width: 70px; padding: 2px 4px; border-radius: 5px; }

.price-stack { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 5px; }

.th-badge { display: inline-flex; align-items: center; gap: 6px; }
.th-badge img { height: 15px; max-width: 58px; object-fit: contain; background: #fff; border-radius: 4px; padding: 1.5px 3px; }

.price { font-weight: 700; font-size: 1rem; }
a.price { text-decoration: none; }
a.price:hover { text-decoration: underline; text-underline-offset: 3px; }
.price.best { color: var(--green); }
.price.worst { color: var(--red); }
.price.na { color: var(--muted); font-weight: 400; }

.diff-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.diff-badge.equal { background: rgba(147, 160, 189, .18); color: var(--muted); }
.diff-badge.mytek-wins { background: rgba(232, 68, 60, .16); color: #ff8a84; }
.diff-badge.tun-wins { background: rgba(47, 127, 232, .16); color: #7db4ff; }
.diff-badge.space-wins { background: rgba(176, 124, 255, .16); color: #c9a8ff; }

th.th-mytek { color: var(--mytek); }
th.th-tun { color: var(--tun); }
th.th-space { color: var(--space); }

.pct { display: block; font-size: 0.75rem; color: var(--muted); font-weight: 400; margin-top: 2px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card > img {
  width: 100%;
  height: 130px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 6px;
}

.card .prod-name { font-size: 0.88rem; }
.card .price { font-size: 1.05rem; }
.card .store-badge.sb-lg { align-self: flex-start; margin-top: 2px; }

.empty, .loading { color: var(--muted); text-align: center; padding: 30px 0; }
.error { color: var(--red); text-align: center; padding: 30px 0; }

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  padding: 20px 0 30px;
  text-align: center;
}
.site-footer a { color: var(--muted); }
.site-footer .footer-brand { color: var(--text); font-weight: 800; letter-spacing: -0.2px; }

@media (max-width: 720px) {
  .site-header h1 { font-size: 1.5rem; }
  .cmp-table th, .cmp-table td { padding: 9px 8px; font-size: 0.85rem; }
  .cmp-table { min-width: 800px; }
  .prod-thumb { display: none; }
  .store-badge { font-size: 0.62rem; padding: 1px 7px 1px 3px; }
  .store-badge img { height: 11px; max-width: 44px; padding: 1px 2px; }
}
