:root {
  --primary: #0058a3;
  --primary-dark: #003d72;
  --primary-alt: #003399;
  --accent: #ffdb00;
  --cheap: #28a745;
  --cheap-light: #5cd874;
  --exp: #dc3545;
  --exp-light: #ff6b6b;
  --bg: #f7f8fb;
  --card: #ffffff;
  --text: #1d1d1f;
  --muted: #6b7280;
  --border: #e5e7eb;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--primary);
  color: white;
  border-bottom: 4px solid var(--accent);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.brand {
  color: white;
  font-weight: 700;
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  background: var(--accent);
  color: var(--primary-dark);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 16px;
  letter-spacing: 1px;
}
.brand-text { opacity: .95; }
.meta { font-size: 13px; opacity: .9; }

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 80px;
  display: grid;
  gap: 20px;
}

.card {
  background: var(--card);
  border-radius: 8px;
  padding: 24px 28px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.card h2 {
  margin: 0 0 16px;
  font-size: 20px;
  color: var(--primary-dark);
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.card h2 small {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.filters-card { padding-bottom: 18px; }
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 18px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
}
.field select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  min-width: 140px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: white;
}
.seg-opt {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background .15s, color .15s;
  user-select: none;
}
.seg-opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
.seg-opt:hover { background: #f0f1f4; }
.seg-opt:has(input:checked) {
  background: var(--primary);
  color: white;
}
.seg-opt:has(input:checked):hover { background: var(--primary-dark); }

.btn {
  font: inherit;
  padding: 9px 18px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover { background: #f0f1f4; }
.btn.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary-dark);
}
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger {
  background: var(--exp);
  color: white;
  border-color: #b02736;
}
.btn.danger:hover { background: #b02736; }

.filters-foot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.scan-info { color: var(--muted); }

.rescan-msg {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 14px;
  border: 1px solid transparent;
}
.rescan-msg[hidden] { display: none; }
.rescan-msg.pending { background: #fffbe6; border-color: #ffe58f; color: #ad6800; }
.rescan-msg.warn    { background: #fff7e6; border-color: #ffd591; color: #ad4e00; }
.rescan-msg.err     { background: #fff1f0; border-color: #ffa39e; color: #a8071a; }
.rescan-msg.ok      { background: #f6ffed; border-color: #b7eb8f; color: #135200; }

.rescan-form {
  margin-top: 12px;
  padding: 12px 14px;
  background: #f9fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.rescan-form label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.rescan-form input[type="password"] {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  min-width: 220px;
  flex: 1 0 220px;
}

.rescan-status {
  margin-top: 12px;
  padding: 12px 14px;
  background: #f9fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.rs-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  font-size: 13px;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  background: #e5e7eb;
  color: #374151;
}
.badge.running      { background: #fff7e6; color: #ad4e00; }
.badge.finished     { background: #f6ffed; color: #135200; }
.badge.failed       { background: #fff1f0; color: #a8071a; }
.badge.interrupted  { background: #f4f4f5; color: #52525b; }

.bar-track-progress {
  height: 10px;
  background: #eef0f4;
  border-radius: 5px;
  overflow: hidden;
}
.bar-fill-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-alt));
  border-radius: 5px;
  transition: width .4s ease;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  padding: 12px 18px;
  background: var(--text);
  color: white;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,.18);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .25s, transform .25s;
  font-size: 14px;
  max-width: 380px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok   { background: var(--cheap); }
.toast.err  { background: var(--exp); }
.toast.warn { background: #ad6800; }

.table-wrap { overflow-x: auto; }
.rank {
  width: 100%;
  border-collapse: collapse;
}
.rank th, .rank td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  white-space: nowrap;
}
.rank th {
  background: #fafbfd;
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.rank th.left, .rank td.left { text-align: left; white-space: normal; }
.rank tbody tr:hover { background: #fafbfd; }
.rank .muted { color: var(--muted); }
.rank .cheap { color: var(--cheap); font-weight: 600; }
.rank .exp { color: var(--exp); font-weight: 600; }
.rank .cc {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 2px;
}
.rank .eur { font-variant-numeric: tabular-nums; }
.rank .code {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  margin-top: 2px;
}
.product-link { color: var(--text); }
.product-link:hover { color: var(--primary); }

.empty {
  text-align: center;
  padding: 32px;
  color: var(--muted);
}
.empty code {
  background: #f0f1f4;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
}

.bars {
  display: grid;
  gap: 4px;
}
.bar-row {
  display: grid;
  grid-template-columns: 80px 140px 1fr 90px;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}
.bar-row:hover { background: #fafbfd; text-decoration: none; }
.bar-row .bar-country, .bar-row .country { font-weight: 700; }
.bar-row .bar-text, .bar-row .price-text {
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-row .bar, .bar-row .bar-track {
  height: 14px;
  background: #eef0f4;
  border-radius: 7px;
  overflow: hidden;
}
.bar-row .bar-fill {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: 7px;
  transition: width .3s ease;
}
.bar-row.cheap .bar-fill {
  background: linear-gradient(90deg, var(--cheap) 0%, var(--cheap-light) 100%);
}
.bar-row.exp .bar-fill {
  background: linear-gradient(90deg, var(--exp) 0%, var(--exp-light) 100%);
}
.bar-row .eur, .bar-row .bar-eur {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.cards { display: grid; gap: 28px; }
.product-card {
  border-left: 4px solid var(--primary-alt);
  padding: 14px 0 14px 20px;
  scroll-margin-top: 20px;
}
.product-card h3 {
  font-size: 17px;
  color: var(--text);
  margin: 0 0 6px;
  font-weight: 600;
}
.product-card h3 code {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  font-family: ui-monospace, monospace;
}
.card-head { margin-bottom: 12px; }
.card-meta {
  color: var(--muted);
  font-size: 13px;
}
.card-meta .pct-big {
  color: var(--exp);
  font-weight: 700;
  font-size: 15px;
}

.back { font-size: 13px; }
.muted { color: var(--muted); }

.foot {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 28px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 720px) {
  .filters { gap: 12px; }
  .field select { min-width: 110px; }
  .rank th, .rank td { padding: 8px; font-size: 13px; }
  .bar-row { grid-template-columns: 50px 1fr 70px; }
  .bar-row .price-text { display: none; }
}
