:root {
  --bg: #f5f6f7;
  --card: #ffffff;
  --text: #1d2125;
  --muted: #6b747c;
  --line: #e3e6e9;
  --accent: #2a8d9c;
  --accent-soft: #e3f2f4;
  --green: #2f8a4c;
  --green-soft: #e4f3e8;
  --red: #c0392b;
  --red-soft: #fbe7e4;
  --orange: #b26a00;
  --orange-soft: #fbf0dc;
  --gray-soft: #eceef0;
  --brocard: #2a8d9c;
  --yr: #6f8f2e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181b;
    --card: #1e2226;
    --text: #e6e8ea;
    --muted: #98a1a9;
    --line: #2e3439;
    --accent: #4fb3c2;
    --accent-soft: #1f3a3f;
    --green: #5cc27c;
    --green-soft: #1f3527;
    --red: #ef7a6c;
    --red-soft: #3d2320;
    --orange: #e3a54d;
    --orange-soft: #3a2f1c;
    --gray-soft: #2a2f34;
    --brocard: #4fb3c2;
    --yr: #9fbf5a;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
main { max-width: 1400px; margin: 0 auto; padding: 16px; }

.top {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.logo { font-weight: 700; font-size: 17px; color: var(--text); }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.top nav a { padding: 6px 10px; border-radius: 6px; color: var(--muted); }
.top nav a.on, .top nav a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; overflow-x: auto; }
.grid { display: grid; gap: 16px; }
.grid.shops { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.grid > .card { margin-bottom: 0; }
.grid + .card, .grid + .grid { margin-top: 16px; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 12px; }
.kpi { display: block; font-size: 24px; font-weight: 700; }
.run { margin: 8px 0; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); padding: 6px 8px; white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.down { color: var(--green); font-weight: 600; }
.up { color: var(--red); font-weight: 600; }

.price { font-weight: 600; }
.old { color: var(--muted); text-decoration: line-through; margin-left: 6px; font-size: 12px; }
.disc { color: var(--red); margin-left: 6px; font-size: 12px; font-weight: 600; }
.big { font-size: 20px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; }
.shop-brocard { background: var(--brocard); }
.shop-yr { background: var(--yr); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 12px; white-space: nowrap; }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.orange { background: var(--orange-soft); color: var(--orange); }
.tag.gray { background: var(--gray-soft); color: var(--muted); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
input, select, button {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px;
}
input[type=search] { flex: 1; min-width: 220px; }
button { background: var(--accent); border-color: var(--accent); color: #fff; cursor: pointer; }
.reset { color: var(--muted); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { padding: 5px 12px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); color: var(--text); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip b { margin-left: 4px; }

.pager { display: flex; gap: 16px; justify-content: center; align-items: center; margin: 8px 0 24px; }

.product { display: flex; gap: 24px; align-items: flex-start; }
.product img { width: 180px; height: 180px; object-fit: contain; background: #fff; border-radius: 8px; flex: none; }
.chart { position: relative; height: 280px; margin-bottom: 16px; }

.bar { display: inline-block; height: 6px; width: calc(var(--w) * 0.6); max-width: 60px; background: var(--accent); border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.compare tr.best td { background: var(--green-soft); }

.login { max-width: 340px; margin: 12vh auto; display: flex; flex-direction: column; gap: 10px; }
.login h1 { margin: 0; }
.login p { margin: 0 0 8px; }
.error { color: var(--red); }

@media (max-width: 720px) {
  main { padding: 10px; }
  .top { gap: 6px 10px; justify-content: space-between; }
  .top nav { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; }
  .top nav a { white-space: nowrap; }
  .grid.two { grid-template-columns: 1fr; }
  .product { flex-direction: column; }
  .product img { width: 120px; height: 120px; }
  td, th { padding: 6px 5px; }
}
