/* ── Design tokens ──────────────────────────────────────────────────────── */

:root {
  --bg: #eef1f8;
  --panel: #ffffff;
  --line: #e5e8f2;
  --line-soft: #eef1f7;
  --ink: #101426;
  --ink-soft: #3a4258;
  --muted: #7c8499;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-dark: #4338ca;
  --brand-soft: #eef2ff;
  --brand-line: #c7d2fe;
  --up: #e11d48;
  --up-soft: #fff1f5;
  --down: #059669;
  --down-soft: #ecfdf5;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --warn-line: #fcd34d;
  --danger: #9f1239;
  --danger-bg: #fff1f2;
  --danger-line: #fecdd3;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-xs: 0 1px 2px rgba(16, 20, 38, .05);
  --shadow-sm: 0 2px 6px -2px rgba(16, 20, 38, .08), 0 1px 2px rgba(16, 20, 38, .05);
  --shadow-md: 0 14px 30px -18px rgba(16, 20, 38, .35), 0 4px 10px -6px rgba(16, 20, 38, .12);
  --ring: 0 0 0 4px rgba(79, 70, 229, .16);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 520px at 92% -8%, rgba(124, 58, 237, .10), transparent 60%),
    radial-gradient(900px 480px at -6% 4%, rgba(79, 70, 229, .10), transparent 55%),
    var(--bg);
  color: var(--ink);
  font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(79, 70, 229, .22); }

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

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background:
    radial-gradient(900px 240px at 88% -30%, rgba(139, 92, 246, .45), transparent 62%),
    linear-gradient(135deg, #171a35 0%, #242261 52%, #30256f 100%);
  color: #fff;
  padding: 13px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .09);
  box-shadow: 0 18px 40px -26px rgba(9, 12, 32, .95);
  backdrop-filter: blur(6px);
}
.topbar .inner, .wrap { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-logo {
  max-width: 145px;
  object-fit: cover; object-position: top center;
  background: #fff; border-radius: 11px; padding: 3px;
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .9);
  flex: none;
}
.brand h1 {
  margin: 0; font-size: 17px; font-weight: 750;
  line-height: 1.25; letter-spacing: -.01em;
  max-width: min(620px, 58vw);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.brand h1.wordmark {
  font-size: 19px; font-weight: 800;
  letter-spacing: .07em; text-transform: uppercase;
}
.brand-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 500; line-height: 1;
  padding: 5px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, .10);
  border: 1px solid rgba(255, 255, 255, .13);
  color: rgba(255, 255, 255, .82);
  white-space: nowrap;
}
.pill strong { color: #fff; font-weight: 750; }
.pill a { color: #a5b4fc; font-weight: 650; text-decoration: none; }
.pill a:hover { color: #fff; text-decoration: none; }
#totalitems-top { color: #fff; font-weight: 750; }

.source-form { display: flex; align-items: center; gap: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.source-form label { color: #c4b5fd; font-weight: 650; }
.source-form select {
  padding: 8px 11px; border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, .28);
  background: rgba(255, 255, 255, .13);
  color: #fff; font-size: 13px; letter-spacing: 0; text-transform: none;
  transition: background .15s ease, border-color .15s ease;
}
.source-form select:hover { background: rgba(255, 255, 255, .2); }
.source-form select:focus { outline: none; border-color: #a5b4fc; box-shadow: 0 0 0 4px rgba(165, 180, 252, .22); }
.source-form select option { color: var(--ink); background: #fff; }
.source-form button { padding: 7px 13px; }

/* ── Layout ─────────────────────────────────────────────────────────────── */

.wrap { padding-top: 22px; padding-bottom: 56px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.panel > h2 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 750;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.panel > h2::before {
  content: "";
  width: 4px; height: 15px;
  align-self: center;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  flex: none;
}
.panel > h2 .hint { font-weight: 450; font-size: 12.5px; color: var(--muted); }
.panel > h2 .spacer { flex: 1; }

/* ── Stat cards ─────────────────────────────────────────────────────────── */

.cards { margin-bottom: 18px; }
.row { margin-top: 0; }
.row > * > .panel { margin-bottom: 0; }
.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand-line);
}
.card .label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  font-weight: 700;
}
.card .value { font-size: 26px; font-weight: 780; margin-top: 6px; line-height: 1.1; letter-spacing: -.02em; }
.card .sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.card.accent {
  background: linear-gradient(140deg, #eef2ff 0%, #f6f2ff 100%);
  border-color: var(--brand-line);
}
.card.accent::after {
  content: "";
  position: absolute; right: -34px; top: -46px;
  width: 110px; height: 110px; border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 58, 237, .18), transparent 68%);
}
.card.up-card { border-left: 4px solid var(--up); }
.card.down-card { border-left: 4px solid var(--down); }
.card .value .sep { color: var(--muted); font-weight: 400; margin: 0 2px; }
.card.wide { padding: 15px 20px; }
.card.wide .wide-inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 26px;
}
.card.wide .wide-text { min-width: 0; }
.card.wide .value { margin-top: 0; font-size: 28px; }

/* ── Result lines / table notes ─────────────────────────────────────────── */

.result-line { margin: 0 0 11px; font-size: 13px; color: var(--muted); }
.result-line strong { color: var(--ink); font-size: 14.5px; font-weight: 750; }
.table-note { margin: 9px 2px 0; }

/* ── AJAX loading state ─────────────────────────────────────────────────── */

.is-loading {
  opacity: .4;
  pointer-events: none;
  transition: opacity .14s ease-in;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .is-loading { transition: none; }
  .card, .grow-card { transition: none !important; }
  .card:hover, .grow-card:hover { transform: none; }
}

/* ── Compact controls in a panel heading ────────────────────────────────── */

.mini {
  display: flex; flex-direction: column; gap: 3px;
  color: var(--muted); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .4px;
  font-weight: 650;
}
.mini input, .mini select { padding: 6px 8px; font-size: 13px; border-radius: 8px; }
.mini input[type="number"] { width: 86px; }
.mini.check {
  flex-direction: row; align-items: center; gap: 6px;
  padding-bottom: 7px; white-space: nowrap;
}
.mini.check input { padding: 0; }
.grow-form { font-size: 12px; gap: 10px; }
.grow-form button { padding: 6px 13px; font-size: 13px; border-radius: 9px; }

/* ── Tables ─────────────────────────────────────────────────────────────── */

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
thead th {
  background: rgba(248, 250, 252, .96);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .55px;
  color: var(--muted);
  font-weight: 750;
  white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
tbody tr { transition: background .12s ease; }
tbody tr:hover td { background: #fafbff; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap {
  max-height: 720px; overflow: auto;
  border: 1px solid var(--line); border-radius: 13px;
  background: #fff;
  box-shadow: var(--shadow-xs);
}
.table-wrap, .catlist { scrollbar-width: thin; scrollbar-color: #cbd2e4 transparent; }
.table-wrap::-webkit-scrollbar, .catlist::-webkit-scrollbar { width: 9px; height: 9px; }
.table-wrap::-webkit-scrollbar-thumb, .catlist::-webkit-scrollbar-thumb {
  background: #cbd2e4; border-radius: 99px; border: 2px solid #fff;
}
.table-wrap::-webkit-scrollbar-track, .catlist::-webkit-scrollbar-track { background: transparent; }

.item-cell { display: flex; gap: 11px; align-items: center; min-width: 0; }
.product-head { flex-wrap: wrap; }
.product-text { flex: 1 1 0; min-width: 0; }
.item-cell img, .grow-card img {
  width: 40px; height: 40px; object-fit: contain;
  background: #f8fafc; border: 1px solid var(--line);
  border-radius: 9px; flex: none;
}
.product-img {
  width: 150px !important; height: 150px !important;
  border-radius: 14px !important; padding: 10px;
}
.item-cell a.item-name, .item-name { font-weight: 650; color: var(--ink); }
.item-cell a.item-name:hover, .item-name:hover { color: var(--brand); text-decoration: none; }
.item-cell .muted, .muted { color: var(--muted); font-size: 12px; }
.muted a { color: var(--muted); }

/* ── Tags / states ──────────────────────────────────────────────────────── */

.tag {
  display: inline-block; font-size: 10.5px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
  letter-spacing: .1px;
}
.tag.yes { background: var(--down-soft); color: #047857; box-shadow: inset 0 0 0 1px #a7f3d0; }
.tag.no { background: #f4f6fa; color: #64748b; box-shadow: inset 0 0 0 1px #e5e9f2; }
.tag.promo { background: #fffbeb; color: #b45309; box-shadow: inset 0 0 0 1px #fde68a; }
.tag.flag { background: var(--danger-bg); color: var(--danger); box-shadow: inset 0 0 0 1px #fecdd3; }
.tag.info { background: #eff6ff; color: #1d4ed8; box-shadow: inset 0 0 0 1px #bfdbfe; }

.up { color: var(--up); font-weight: 700; }
.down { color: var(--down); font-weight: 700; }
.flat { color: var(--muted); font-weight: 600; }
a.up:hover, a.down:hover { text-decoration: none; filter: brightness(.85); }

/* ── Forms ──────────────────────────────────────────────────────────────── */

.filters label {
  display: flex; flex-direction: column; font-size: 11px; font-weight: 700;
  color: var(--muted); gap: 5px; text-transform: uppercase; letter-spacing: .45px;
}
.filters input:not([type="checkbox"]), .filters select { width: 100%; }
input, select, button, textarea {
  font: inherit;
  padding: 8px 11px;
  border: 1px solid #d8dcea;
  border-radius: var(--radius-sm);
  background: #fff;
  color: inherit;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input::placeholder { color: #a3abbd; }
input:hover, select:hover { border-color: #bcc3d6; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}
input[type="checkbox"], input[type="radio"] {
  appearance: none;
  width: 18px; height: 18px;
  padding: 0; margin: 0;
  border: 1.5px solid #c3c9db;
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  flex: none;
  transition: background .13s ease, border-color .13s ease, box-shadow .13s ease;
}
input[type="checkbox"]:hover, input[type="radio"]:hover { border-color: var(--brand); }
input[type="checkbox"]:checked {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent;
  box-shadow: inset 0 0 0 3px #fff;
}
input[type="checkbox"]:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
button, .btn {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; display: inline-block;
  font-size: 14px; font-weight: 650;
  border-radius: var(--radius-sm);
  padding: 8px 15px;
  box-shadow: 0 8px 18px -10px rgba(79, 70, 229, .85);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
button:hover, .btn:hover {
  filter: brightness(1.06);
  box-shadow: 0 12px 24px -10px rgba(79, 70, 229, .9);
  text-decoration: none;
}
button:active, .btn:active { transform: translateY(1px); box-shadow: 0 6px 14px -10px rgba(79, 70, 229, .8); }
.btn.ghost {
  background: #fff; color: var(--brand);
  border: 1px solid var(--brand-line);
  box-shadow: none;
}
.btn.ghost:hover { background: var(--brand-soft); border-color: var(--brand); filter: none; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Notices ────────────────────────────────────────────────────────────── */

.notice {
  background: var(--warn-bg); border: 1px solid var(--warn-line);
  color: var(--warn); border-left-width: 4px;
  border-radius: 12px; padding: 12px 15px;
  font-size: 13.5px; line-height: 1.55; margin-bottom: 15px;
}
.notice.danger { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }
.notice strong { font-weight: 750; }
.notice a { font-weight: 650; }
.notice code, code { background: rgba(16, 20, 38, .07); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }

/* ── Growth cards ───────────────────────────────────────────────────────── */

.grow-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 15px 14px 17px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 9px;
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.grow-card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--up), #f97316);
}
.grow-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: #fbbf24;
}
.grow-card.suspect { background: #fffdf6; }
.grow-card.suspect::before { background: linear-gradient(180deg, #f59e0b, #fbbf24); }
.grow-card .head { display: flex; gap: 11px; align-items: flex-start; }
.grow-card .head img { width: 46px; height: 46px; background: #fff; }
.grow-card .name { font-weight: 700; font-size: 14px; line-height: 1.35; color: var(--ink); }
.grow-card .name:hover { color: var(--brand); text-decoration: none; }
.grow-card .where { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.grow-card .where a { text-decoration: none; }
.grow-card .where a:hover { text-decoration: underline; }
.grow-card .prices {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; flex-wrap: wrap;
  background: #f8fafc;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 8px 10px;
}
.grow-card .prices .p { font-variant-numeric: tabular-nums; font-weight: 750; }
.grow-card .prices .when { color: var(--muted); font-size: 11.5px; }
.grow-card .prices .arrow { color: var(--brand); font-weight: 700; }
.grow-card .foot {
  display: flex; align-items: center; gap: 10px;
  border-top: 1px dashed var(--line);
  padding-top: 9px; margin-top: auto; flex-wrap: wrap;
}
.grow-card .diff { font-weight: 750; font-size: 15px; color: var(--up); font-variant-numeric: tabular-nums; }
.grow-card .pctval {
  font-weight: 750; font-size: 13px; color: var(--up);
  font-variant-numeric: tabular-nums;
  background: var(--up-soft);
  padding: 3px 8px; border-radius: 999px;
  box-shadow: inset 0 0 0 1px #fecdd3;
}
.grow-card .more { margin-left: auto; font-size: 12.5px; font-weight: 650; }

.spark { display: inline-flex; align-items: flex-end; gap: 2px; height: 30px; }
.spark-bar { display: block; width: 5px; background: #d7dcea; border-radius: 3px 3px 0 0; }
.spark-bar:last-child { background: linear-gradient(180deg, var(--brand), var(--brand-2)); }

/* ── Summary bars ───────────────────────────────────────────────────────── */

.bar-row { margin-bottom: 11px; }
.bar-row .bl { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }
.bar-row .bl span:last-child { font-variant-numeric: tabular-nums; font-weight: 750; }
.bar-track { height: 9px; background: #eef1f7; border-radius: 999px; overflow: hidden; box-shadow: inset 0 1px 2px rgba(16, 20, 38, .06); }
.bar-fill { height: 100%; border-radius: 999px; transition: width .4s ease; }
.bar-fill.up { background: linear-gradient(90deg, #fb7185, var(--up)); }
.bar-fill.down { background: linear-gradient(90deg, #34d399, var(--down)); }
.bar-fill.flat { background: linear-gradient(90deg, #cbd5e1, #94a3b8); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

/* ── Category tree ──────────────────────────────────────────────────────── */

.catlist { max-height: 580px; overflow: auto; font-size: 13.5px; margin: 0 -8px; padding: 0 4px; }
.catlist .cat {
  font-size: 10.5px; font-weight: 800; color: var(--brand);
  text-transform: uppercase; letter-spacing: .7px;
  margin: 15px 8px 5px;
}
.catlist .cat:first-child { margin-top: 4px; }
.catlist a {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 7px 10px; border-radius: 9px;
  text-decoration: none; color: var(--ink-soft); font-weight: 550;
  transition: background .13s ease, color .13s ease, transform .13s ease;
}
.catlist a:hover { background: var(--brand-soft); color: var(--brand-dark); text-decoration: none; transform: translateX(2px); }
.catlist a.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-weight: 700;
  box-shadow: 0 8px 16px -10px rgba(79, 70, 229, .9);
}
.catlist a.active .n { color: rgba(255, 255, 255, .8); }
.catlist a .n { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; font-weight: 650; }
.catlist a.sub { padding-left: 20px; color: var(--muted); font-weight: 500; }
.catlist a.sub.active { color: #fff; }

/* ── Pager / misc ───────────────────────────────────────────────────────── */

.pager { display: flex; gap: 7px; align-items: center; justify-content: center; margin-top: 16px; font-size: 13.5px; }
.pager a {
  text-decoration: none; color: var(--brand);
  background: #fff; border: 1px solid var(--brand-line);
  padding: 6px 13px; border-radius: 9px; font-weight: 650;
  transition: background .13s ease, transform .13s ease;
}
.pager a:hover { background: var(--brand-soft); transform: translateY(-1px); text-decoration: none; }
.pager span { color: var(--muted); font-variant-numeric: tabular-nums; padding: 0 6px; }
.empty {
  padding: 34px 26px; text-align: center; color: var(--muted);
  font-size: 14.5px; line-height: 1.6;
}
footer {
  text-align: center; color: var(--muted); font-size: 12px;
  padding: 14px 0 0; margin-top: 8px;
  border-top: 1px solid var(--line);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 760px) {
  .topbar { padding: 11px 0; }
  .topbar .inner, .wrap { padding: 0 14px; }
  .topbar-row { gap: 12px; }
  .brand { gap: 11px; }
  .brand-logo { width: 50px; height: 38px; }
  .brand h1, .brand h1.wordmark { font-size: 16px; max-width: 78vw; }
  .pill { font-size: 11px; padding: 4px 8px; }
  .brand-meta .pill:nth-child(2) { display: none; }
  .wrap { padding-top: 16px; }
  .panel { padding: 15px 14px; border-radius: 14px; }
  .card { padding: 12px 13px; border-radius: 13px; }
  .card .value { font-size: 22px; }
  .card.wide { padding: 13px 15px; }
  .card.wide .value { font-size: 24px; }
  .product-head { flex-direction: column; align-items: flex-start !important; }
  .product-img { width: 110px !important; height: 110px !important; }
  .table-wrap { max-height: 60vh; }
  th, td { padding: 9px 10px; }
  .source-form select { max-width: 190px; }
}

