/* ModeSens trending demo — dense analytical UI */
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1d2129;
  --border: #262b36;
  --text: #e6e9f2;
  --muted: #8791a3;
  --accent: #6ea8ff;
  --accent-2: #91f3c9;
  --warn: #ffbd66;
  --danger: #ff7676;
  --row-hover: #22283340;
  --row-selected: #2b3a5c;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }

/* Top progress bar — visible only while `body.is-loading`. Sits above the
   header so it survives any scroll position. */
.top-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 999;
  overflow: hidden; background: transparent; pointer-events: none;
  opacity: 0; transition: opacity 120ms ease;
}
body.is-loading .top-progress { opacity: 1; }
.top-progress .bar {
  height: 100%; width: 40%;
  background: linear-gradient(90deg, transparent, var(--accent) 30%,
              var(--accent-2) 70%, transparent);
  animation: topbar 1.1s ease-in-out infinite;
}
@keyframes topbar {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}

/* Suppress control interactions while loading — a subtle dim rather than
   full-block, so filters still look inspectable. */
body.is-loading .filter-bar,
body.is-loading .view-tabs { pointer-events: none; opacity: 0.7; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB",
               "Noto Sans", sans-serif;
  font-size: 13px;
}

/* Header */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.brand {
  font-weight: 600; letter-spacing: 0.3px;
  color: inherit; text-decoration: none;
}
.brand:hover { color: var(--accent); }
.meta { color: var(--muted); font-size: 12px; }

/* Filter bar */
.filter-bar {
  display: flex; align-items: flex-end; flex-wrap: wrap; gap: 16px;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label {
  color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.4px;
}
.filter-group input[type=date],
.filter-group select {
  background: #0e1218; color: var(--text); border: 1px solid var(--border);
  padding: 6px 8px; border-radius: 4px; font: inherit; height: 30px;
}
.filter-group .dash { color: var(--muted); padding: 0 4px; }
.date-range { display: inline-flex; align-items: center; gap: 4px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 4px;
       overflow: hidden; }
.seg button {
  background: #0e1218; color: var(--text); border: 0;
  padding: 6px 10px; font: inherit; cursor: pointer;
  border-right: 1px solid var(--border);
}
.seg button:last-child { border-right: 0; }
.seg button[data-active="true"] { background: var(--accent); color: #0a0f19; font-weight: 600; }
.seg button:hover:not([data-active="true"]) { background: #1a2030; }
/* Disabled selects (e.g., Traffic when Order/Sales/CVR force 'all') */
.filter-group select:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-refresh {
  background: #0e1218; border: 1px solid var(--border); color: var(--text);
  padding: 6px 12px; border-radius: 4px; height: 30px; cursor: pointer;
  font-size: 14px;
}
.btn-refresh:hover { background: #1a2030; }

/* View tabs */
.view-tabs {
  display: flex; gap: 4px; padding: 6px 20px 0 20px; border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.view-tabs button {
  background: transparent; color: var(--muted); border: 0;
  padding: 10px 14px; font: inherit; cursor: pointer;
  border-bottom: 2px solid transparent;
}
.view-tabs button[data-active="true"] {
  color: var(--text); border-bottom-color: var(--accent); font-weight: 600;
}
.view-tabs button:hover:not([data-disabled="true"]) { color: var(--text); }
.view-tabs button[data-disabled="true"] { color: #4a5262; cursor: not-allowed; }

/* Breadcrumb */
.breadcrumb {
  padding: 8px 20px; color: var(--muted); font-size: 12px; min-height: 24px;
  border-bottom: 1px solid var(--border); background: var(--panel-2);
}
.breadcrumb .crumb-current { color: var(--text); font-weight: 500; }
.breadcrumb a {
  color: var(--accent); text-decoration: none; cursor: pointer;
}
.breadcrumb a:hover { text-decoration: underline; }

/* Content */
.content { padding: 12px 20px; }
.panel.hidden { display: none; }

/* Category x Brand three-column layout */
.cxb-cols {
  display: grid; grid-template-columns: 240px 320px minmax(0, 1fr); gap: 12px;
  align-items: start;
}
.cxb-col { min-width: 0; }  /* allow shrinking so overflow can kick in */
.cxb-col > h4 {
  margin: 0 0 6px 0; color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.4px;
}
@media (max-width: 1024px) {
  .cxb-cols { grid-template-columns: 1fr; }
}

/* Wide tables (product table has 14 cols) scroll horizontally inside their
   container rather than pushing the grid layout. */
.tbl-wrap { overflow-x: auto; max-width: 100%; }
.tbl-wrap > table.tbl { min-width: max-content; }

/* Tables */
table.tbl {
  width: 100%; border-collapse: collapse; background: var(--panel);
  border: 1px solid var(--border); border-radius: 4px; overflow: hidden;
}
table.tbl th, table.tbl td {
  padding: 8px 10px; border-bottom: 1px solid var(--border);
  text-align: left; vertical-align: middle; white-space: nowrap;
}
table.tbl th {
  background: var(--panel-2); color: var(--muted); font-weight: 500;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px;
  position: sticky; top: 0;
}
table.tbl tbody tr:hover { background: var(--row-hover); }
table.tbl tbody tr[data-selected="true"] {
  background: var(--row-selected);
  box-shadow: inset 3px 0 0 var(--accent);
}
/* Summary rows (brand / category) are clickable to drill; product rows are not. */
table.tbl tbody tr[data-brand],
table.tbl tbody tr[data-category] { cursor: pointer; }
#drill-anchor { scroll-margin-top: 12px; }

.tbl .rank { color: var(--muted); width: 40px; }
.tbl .metric { color: var(--accent-2); font-weight: 600; }
.tbl .brand-link, .tbl .cat-link, .tbl a.pid-link {
  color: var(--accent); cursor: pointer; text-decoration: none;
}
.tbl .brand-link:hover, .tbl .cat-link:hover, .tbl a.pid-link:hover {
  text-decoration: underline;
}
.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl th.num { text-align: right; }
.tbl .prod-cell { display: flex; gap: 10px; align-items: center; min-width: 260px; }
.tbl .prod-cell img {
  width: 42px; height: 42px; border-radius: 4px; object-fit: cover;
  background: #0a0d13; border: 1px solid var(--border);
}
.tbl .prod-cell .pn { max-width: 260px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.tbl .prod-cell .brand { color: var(--muted); font-size: 11px; }

.tbl .placeholder-img {
  width: 42px; height: 42px; border-radius: 4px;
  background: repeating-linear-gradient(45deg, #191d26, #191d26 6px, #12151b 6px, #12151b 12px);
  border: 1px solid var(--border);
}

.price-tag .sale { font-weight: 600; }
.price-tag .list { color: var(--muted); text-decoration: line-through;
  margin-left: 4px; font-size: 11px; }
.price-tag .disc { color: var(--warn); margin-left: 4px; font-size: 11px; }

.dim { color: var(--muted); }
.empty {
  padding: 40px 20px; text-align: center; background: var(--panel);
  border: 1px dashed var(--border); border-radius: 4px;
}
.empty-title { color: var(--muted); }
.empty-sub { color: var(--muted); font-size: 11px; margin-top: 4px; }

.skeleton {
  display: grid; gap: 8px; padding: 8px;
}
.skeleton div {
  height: 40px; background: linear-gradient(90deg, #191d26, #21262f, #191d26);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 4px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.error-box {
  padding: 20px; background: #2a1417; border: 1px solid #522328;
  color: var(--danger); border-radius: 4px;
}
.error-detail { color: var(--muted); font-size: 11px; margin-top: 6px; }

/* Floating image preview shown on cover hover in product tables.
   Position/size set via JS relative to the hovered thumbnail. */
.img-preview {
  position: fixed; z-index: 1000; pointer-events: none;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  opacity: 0; visibility: hidden;
  transition: opacity 120ms ease;
}
.img-preview.visible { opacity: 1; visibility: visible; }
.img-preview img {
  display: block; width: 320px; height: 320px; object-fit: contain;
  background: #0a0d13; border-radius: 4px;
}
.prod-cell img { cursor: zoom-in; }

/* ---- Access-token gate page --------------------------------------------- */
/* Minimalist centered card: brand line, hint, single big input, button. */
.gate-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; margin: 0; padding: 20px;
  background: var(--bg);
}
.gate-wrap {
  width: 100%; max-width: 520px;
  padding: 40px 32px;
  text-align: center;
}
.gate-brand {
  font-size: 20px; font-weight: 600; letter-spacing: 0.3px;
  color: var(--text); margin-bottom: 6px;
}
.gate-hint {
  color: var(--muted); font-size: 13px; margin-bottom: 28px;
}
.gate-form {
  display: flex; flex-direction: column; gap: 12px;
}
.gate-input {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 18px 20px;
  font-size: 20px; font-family: inherit;
  text-align: center; letter-spacing: 0.4px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.gate-input::placeholder { color: #4a5262; letter-spacing: 0.2px; }
.gate-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(110, 168, 255, 0.15);
}
.gate-btn {
  background: var(--accent); color: #0a0f19;
  border: 0; border-radius: 6px;
  padding: 12px 20px;
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer;
  transition: background 120ms ease;
}
.gate-btn:hover { background: var(--accent-2); }
.gate-error {
  color: var(--danger); font-size: 12px;
  padding: 10px 14px;
  background: #2a1417; border: 1px solid #522328;
  border-radius: 4px;
}

.subtitle-h { margin: 12px 4px 6px 4px; color: var(--muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }

/* ---- Landing page ---------------------------------------------------- */

.landing {
  max-width: 1080px; margin: 0 auto; padding: 32px 20px 60px 20px;
}

.landing-hero { margin-bottom: 24px; }
.landing-hero h1 {
  margin: 0 0 8px 0; font-size: 22px; font-weight: 600;
  letter-spacing: -0.2px;
}
.landing-hero p { margin: 0; color: var(--muted); font-size: 13px; }

.landing-tiles {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
  margin-bottom: 36px;
}
@media (max-width: 720px) {
  .landing-tiles { grid-template-columns: 1fr; }
}
.tile {
  display: block; padding: 16px 18px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; text-decoration: none; color: inherit;
  transition: border-color 100ms ease, transform 100ms ease;
  border-left: 3px solid var(--accent);
}
.tile:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.tile-title {
  font-weight: 600; font-size: 14px; color: var(--text); margin-bottom: 4px;
}
.tile-question {
  color: var(--muted); font-size: 12px; margin-bottom: 6px;
}
.tile-sub {
  font-size: 11px; color: var(--accent-2); font-variant-numeric: tabular-nums;
}

.landing-explore {
  text-align: center; margin: -12px 0 32px 0;
  color: var(--muted); font-size: 12px;
}
.landing-explore a { color: var(--accent); text-decoration: none; }
.landing-explore a:hover { text-decoration: underline; }

.landing-info {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
@media (max-width: 900px) {
  .landing-info { grid-template-columns: 1fr; }
}
.info-block {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; padding: 16px;
}
.info-block h3 {
  margin: 0 0 10px 0; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.4px; color: var(--muted); font-weight: 500;
}
.info-block dl { margin: 0; }
.info-block dt {
  font-size: 12px; font-weight: 600; color: var(--text);
  margin-top: 8px;
}
.info-block dt:first-child { margin-top: 0; }
.info-block dd {
  margin: 2px 0 0 0; font-size: 12px; color: var(--muted); line-height: 1.4;
}
.info-block code {
  background: #0e1218; padding: 1px 5px; border-radius: 3px;
  font-size: 11px; color: var(--accent-2);
}
.info-block ul.notes {
  margin: 0; padding-left: 16px;
}
.info-block ul.notes li {
  font-size: 12px; color: var(--muted); line-height: 1.5;
  margin-bottom: 6px;
}
.info-block ul.notes strong { color: var(--text); font-weight: 600; }
