/* Trend Scanner page (templates/trend_scanner.html). A versioned static file, cached for a year,
   instead of 17 KB of CSS repeated in every copy of the page. */
:root {
  --up:   #22c55e;
  --dn:   #ef4444;
  --rng:  #f59e0b;
  --card: #0d1829;
  --bdr:  #1a2940;
  --muted:#64748b;
  --dim:  #94a3b8;
}

/* ── HERO ──────────────────────────────────────── */
.tce-hero {
  text-align: center;
  padding: 52px 20px 32px;
}
.tce-badge-pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.25);
  color: var(--up); font-size: .72rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 5px 14px; border-radius: 99px; margin-bottom: 18px;
}
.tce-badge-pill i { width:7px;height:7px;border-radius:50%;background:var(--up);animation:blink 1.8s infinite; }
@keyframes blink { 0%,100%{opacity:1}50%{opacity:.3} }
.tce-hero h1 {
  font-size: clamp(1.9rem,4.5vw,2.9rem);
  font-weight: 800; line-height: 1.12; margin: 0 0 12px;
  background: linear-gradient(130deg,#d1fae5 0%,#34d399 40%,#60a5fa 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.tce-hero p { color: var(--muted); font-size: .95rem; max-width: 520px; margin: 0 auto; line-height: 1.65; }

/* ── CONTROLS ──────────────────────────────────── */
.tce-panel {
  background: var(--card);
  border: 1px solid var(--bdr);
  border-radius: 18px;
  padding: 26px 26px 22px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.tce-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg,var(--up),#60a5fa,transparent);
  opacity: .6;
}
.tce-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.tce-panel-title {
  font-size: .8rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--dim);
  display: flex; align-items: center; gap: 7px;
}
.tce-panel-title svg { width:14px;height:14px; opacity:.7; }

/* grid of filter groups */
.tce-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 28px;
  margin-bottom: 22px;
}
@media (max-width:640px) { .tce-grid { grid-template-columns: 1fr; } }

.tce-group label {
  display: block;
  font-size: .72rem; font-weight: 700; color: var(--muted);
  letter-spacing: .07em; text-transform: uppercase; margin-bottom: 9px;
}

/* price inputs */
.price-row { display: flex; align-items: center; gap: 8px; }
.price-row input {
  flex: 1; min-width: 0;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--bdr);
  border-radius: 9px; color: #e2e8f0;
  font-size: .88rem; padding: 9px 12px;
  outline: none; transition: border-color .18s;
}
.price-row input:focus { border-color: var(--up); }
.price-row span { color: var(--muted); font-size: .85rem; flex-shrink: 0; }

/* quick chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--bdr);
  color: var(--muted);
  font-size: .73rem; font-weight: 700;
  padding: 5px 12px; border-radius: 99px;
  cursor: pointer; transition: all .15s;
  user-select: none;
}
.chip:hover { border-color: rgba(34,197,94,.4); color: #94a3b8; }
.chip.on {
  background: rgba(34,197,94,.13);
  border-color: var(--up); color: var(--up);
}

/* stale results banner */
#staleBanner {
  display: none;
  align-items: center; gap: 10px;
  background: rgba(234,179,8,.08);
  border: 1px solid rgba(234,179,8,.35);
  border-radius: 10px;
  padding: 10px 16px;
  margin: 12px 0 0;
  font-size: .82rem; color: #fbbf24;
}
#staleBanner svg { flex-shrink:0; }
#staleBanner strong { color:#fde68a; }

/* pulse scan button when stale */
@keyframes scanPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,.55); }
  50%      { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
}
.tce-btn-scan.stale { animation: scanPulse 1.6s ease-in-out infinite; }

/* ── SCAN FOOTER ───────────────────────────────── */
.tce-footer {
  display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap;
  border-top: 1px solid var(--bdr); padding-top: 20px;
}
.tce-footer-group { flex: 1; min-width: 160px; }
.tce-footer-group label {
  display: block; font-size: .7rem; font-weight: 700;
  color: var(--muted); letter-spacing: .07em;
  text-transform: uppercase; margin-bottom: 8px;
}
.tce-btn-scan {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg,#22c55e,#16a34a);
  color: #fff; font-size: .9rem; font-weight: 700;
  padding: 12px 30px; border-radius: 11px;
  border: none; cursor: pointer;
  transition: opacity .2s, transform .15s, box-shadow .2s;
  box-shadow: 0 4px 16px rgba(34,197,94,.3);
  white-space: nowrap;
}
.tce-btn-scan:hover:not(:disabled) {
  opacity: .9; transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(34,197,94,.4);
}
.tce-btn-scan:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.tce-btn-scan svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ── PROGRESS ──────────────────────────────────── */
.tce-progress {
  display: none;
  background: var(--card); border: 1px solid var(--bdr);
  border-radius: 14px; padding: 20px 24px;
  margin-bottom: 20px;
}
.tce-progress.show { display: flex; align-items: center; gap: 18px; }
.tce-progress-inner { flex: 1; }
.tce-progress-label {
  font-size: .8rem; color: var(--dim); margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center;
}
.tce-progress-label strong { color: #e2e8f0; }
.tce-bar-outer {
  height: 7px; background: rgba(255,255,255,.06);
  border-radius: 99px; overflow: hidden;
}
.tce-bar-inner {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg,#22c55e,#60a5fa);
  transition: width .5s ease;
  width: 0%;
}
.tce-spinner {
  width: 34px; height: 34px;
  border: 3px solid rgba(34,197,94,.2);
  border-top-color: var(--up);
  border-radius: 50%; flex-shrink: 0;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── STAT CARDS ────────────────────────────────── */
.tce-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
@media (max-width: 600px) { .tce-stats { grid-template-columns: repeat(2,1fr); } }
.tce-stat {
  background: var(--card); border: 1px solid var(--bdr);
  border-radius: 14px; padding: 16px 18px;
  display: flex; align-items: center; gap: 14px;
}
.tce-stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 1.1rem;
}
.tce-stat-icon.all  { background: rgba(148,163,184,.08); }
.tce-stat-icon.up   { background: rgba(34,197,94,.1); }
.tce-stat-icon.dn   { background: rgba(239,68,68,.1); }
.tce-stat-icon.rng  { background: rgba(245,158,11,.1); }
.tce-stat-info {}
.tce-stat-num {
  font-size: 1.5rem; font-weight: 800; line-height: 1;
  margin-bottom: 3px;
}
.tce-stat-lbl { font-size: .7rem; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.tce-stat.all  .tce-stat-num { color: #e2e8f0; }
.tce-stat.up   .tce-stat-num { color: var(--up); }
.tce-stat.dn   .tce-stat-num { color: var(--dn); }
.tce-stat.rng  .tce-stat-num { color: var(--rng); }

/* ── RESULTS HEADER ────────────────────────────── */
.tce-results-header {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 14px;
}
.trend-tab {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.04); border: 1px solid var(--bdr);
  color: var(--muted); font-size: .78rem; font-weight: 700;
  padding: 7px 16px; border-radius: 99px;
  cursor: pointer; transition: all .16s;
}
.trend-tab:hover { color: #94a3b8; border-color: #2a3f5a; }
.trend-tab.t-all  { border-color:#334155; color:#94a3b8; background:rgba(255,255,255,.07); }
.trend-tab.t-up   { border-color:var(--up);  color:var(--up);  background:rgba(34,197,94,.12); }
.trend-tab.t-dn   { border-color:var(--dn);  color:var(--dn);  background:rgba(239,68,68,.12); }
.trend-tab.t-rng  { border-color:var(--rng); color:var(--rng); background:rgba(245,158,11,.12); }
.tce-search-input {
  margin-left: auto;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--bdr);
  border-radius: 9px; color: #e2e8f0;
  font-size: .82rem; padding: 7px 13px;
  outline: none; width: 150px; transition: border-color .18s;
}
.tce-search-input:focus { border-color: var(--up); width: 200px; }
.tce-export {
  background: rgba(255,255,255,.04); border: 1px solid var(--bdr);
  color: var(--muted); font-size: .75rem; font-weight: 600;
  padding: 7px 13px; border-radius: 9px; cursor: pointer;
  transition: all .16s;
}
.tce-export:hover { border-color: var(--up); color: var(--up); }

/* ── TABLE ─────────────────────────────────────── */
.tce-table-scroll { overflow-x: auto; border-radius: 14px; border: 1px solid var(--bdr); }
.tce-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.tce-table th {
  background: rgba(255,255,255,.025);
  color: var(--muted); font-size: .68rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 11px 14px; text-align: left;
  border-bottom: 1px solid var(--bdr);
  cursor: pointer; user-select: none; white-space: nowrap;
}
.tce-table th:hover { color: #94a3b8; }
.tce-table th.asc .si::after  { content:' ↑'; }
.tce-table th.desc .si::after { content:' ↓'; }
.tce-table th .si { color: var(--up); font-size: .65rem; }
.tce-table td {
  padding: 10px 14px; border-bottom: 1px solid rgba(26,41,64,.55);
  vertical-align: middle; white-space: nowrap;
}
.tce-table tr:last-child td { border-bottom: none; }
.tce-table tr:hover td { background: rgba(255,255,255,.022); }

/* badges */
.tb { display:inline-flex;align-items:center;gap:5px;font-size:.7rem;font-weight:700;letter-spacing:.05em;padding:3px 10px;border-radius:99px; }
.tb.up  { background:rgba(34,197,94,.13); color:var(--up);  border:1px solid rgba(34,197,94,.28); }
.tb.dn  { background:rgba(239,68,68,.13); color:var(--dn);  border:1px solid rgba(239,68,68,.28); }
.tb.rng { background:rgba(245,158,11,.13);color:var(--rng); border:1px solid rgba(245,158,11,.28); }
.tb-dot { width:5px;height:5px;border-radius:50%; flex-shrink:0; }
.tb.up  .tb-dot { background:var(--up); }
.tb.dn  .tb-dot { background:var(--dn); }
.tb.rng .tb-dot { background:var(--rng); }
.sec-badge {
  display:inline-block; font-size:.67rem; font-weight:700;
  letter-spacing:.04em; padding:3px 9px; border-radius:99px;
  background:rgba(99,102,241,.13); color:#818cf8;
  border:1px solid rgba(99,102,241,.25); white-space:nowrap;
}

/* confidence bar */
.cf-wrap { display:flex;align-items:center;gap:7px; }
.cf-bar { width:52px;height:5px;border-radius:99px;background:rgba(255,255,255,.07); flex-shrink:0; }
.cf-fill { height:100%;border-radius:99px; }
.cf-fill.up  { background:linear-gradient(90deg,#16a34a,#22c55e); }
.cf-fill.dn  { background:linear-gradient(90deg,#b91c1c,#ef4444); }
.cf-fill.rng { background:linear-gradient(90deg,#b45309,#f59e0b); }
.cf-pct { font-size:.75rem;color:var(--muted); }

.tick-link { color:#e2e8f0;font-weight:700;font-size:.88rem;text-decoration:none; }
.tick-link:hover { color:var(--up); }
.tick-sub { color:var(--muted);font-size:.7rem;margin-top:2px; }
.col-price { font-weight:600;color:#e2e8f0; }
.col-dim   { color:var(--muted);font-size:.82rem; }
.col-pdi   { font-variant-numeric: tabular-nums; }
.col-reason { color:var(--muted);font-size:.73rem;max-width:180px;overflow:hidden;text-overflow:ellipsis; }

/* ── EMPTY ─────────────────────────────────────── */
.tce-empty {
  text-align: center; padding: 72px 20px;
  background: var(--card); border: 1px solid var(--bdr); border-radius: 14px;
}
.tce-empty-icon {
  width: 52px;height:52px;background:rgba(255,255,255,.04);
  border-radius: 13px; display:flex;align-items:center;justify-content:center;
  margin: 0 auto 14px;
}
.tce-empty h3 { font-size:1rem;color:#94a3b8;margin:0 0 7px; }
.tce-empty p  { font-size:.83rem;color:var(--muted);margin:0; }

/* ── SIGNIN WALL ───────────────────────────────── */
.tce-wall {
  text-align: center; padding: 80px 20px;
  background: var(--card); border: 1px solid var(--bdr);
  border-radius: 18px; margin-top: 12px;
}
.tce-wall h2 { font-size:1.35rem;color:#e2e8f0;margin:0 0 10px; }
.tce-wall p  { color:var(--muted);margin:0 0 24px; }
.tce-wall .cta { display:inline-block;background:linear-gradient(135deg,#22c55e,#16a34a);color:#fff;font-weight:700;padding:12px 32px;border-radius:11px;text-decoration:none; }

/* ── MISC ──────────────────────────────────────── */
.scan-meta {
  font-size: .73rem; color: var(--muted);
  text-align: right; margin-top: 10px;
}
.tce-preview-notes {
  margin: 0 0 28px; padding: 18px 20px; color: #cbd5e1;
  background: var(--card); border: 1px solid var(--bdr); border-radius: 14px;
  font-size: .84rem; line-height: 1.65;
}
.tce-preview-notes h2, .tce-preview-notes h3 { margin: 0 0 8px; color: #e2e8f0; font-size: 1rem; }
.tce-preview-notes p { margin: 0 0 10px; }
.tce-preview-notes dl { display: grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap: 8px 18px; margin: 10px 0 14px; }
.tce-preview-notes dt { color: #86efac; font-weight: 700; }
.tce-preview-notes dd { margin: 2px 0 0; color: var(--muted); }
.tce-preview-notes a { color: #86efac; }

/* ── PUBLIC SAMPLE · PAID COMPARISON · EDUCATIONAL EXAMPLE ───── */
.tce-sr { position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);clip-path:inset(50%);white-space:nowrap;border:0; }
.tce-section { margin: 0 0 34px; scroll-margin-top: 84px; }
.tce-section > h2, .tce-illus > h2 { margin: 0 0 6px; color: #e2e8f0; font-size: 1.15rem; }
.tce-lead { margin: 0 0 14px; color: var(--dim); font-size: .86rem; line-height: 1.6; max-width: 72ch; }
.tce-state {
  margin: 0 0 14px; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--bdr);
  background: var(--card); color: #cbd5e1; font-size: .84rem; line-height: 1.6;
}
.tce-state strong { color: #e2e8f0; }
.tce-state-stale { border-color: rgba(245,158,11,.45); background: rgba(245,158,11,.08); }
.tce-state-off { border-style: dashed; border-color: rgba(148,163,184,.4); }
.tce-sample-table th, .tce-unlock-table th { cursor: default; }
.tce-sample-table th:hover, .tce-unlock-table th:hover { color: var(--muted); }
.tce-sample-table tbody th[scope="row"] {
  text-transform: none; letter-spacing: 0; font-size: .84rem; color: #e2e8f0;
  position: sticky; left: 0; background: var(--card);
  padding: 10px 14px; border-bottom: 1px solid rgba(26,41,64,.55);
}
.tce-sample-table tbody th[scope="row"]:hover { color: #e2e8f0; }
.tce-sample-table tr:last-child th[scope="row"] { border-bottom: none; }
.tce-sample-table .tick-sub { display: block; }
.tce-sample-table th, .tce-sample-table td { padding-left: 10px; padding-right: 10px; }
.tce-sample-table thead th { white-space: normal; vertical-align: bottom; line-height: 1.35; }
.tce-sample-table .cf-bar { width: 38px; }
.tce-sample-table td.col-reason { white-space: normal; min-width: 150px; max-width: 210px; color: var(--dim); font-size: .76rem; line-height: 1.45; }
.tce-sample-table td.tce-when { white-space: nowrap; line-height: 1.4; }
.tce-when-tf { display: block; color: #cbd5e1; font-weight: 600; }
.tce-sample-table time { display: block; }
.tce-fit-n { font-variant-numeric: tabular-nums; color: #e2e8f0; font-weight: 600; font-size: .82rem; }
.tce-fit-of { color: var(--dim); font-size: .7rem; margin-left: 1px; }
.tce-sample-foot { margin: 12px 0 0; color: var(--dim); font-size: .78rem; line-height: 1.65; }
.tce-sample-foot p { margin: 0 0 6px; }
.tce-unlock-table tbody th[scope="row"] {
  text-align: left; color: #e2e8f0; font-size: .84rem; text-transform: none; letter-spacing: 0;
  padding: 10px 14px; border-bottom: 1px solid rgba(26,41,64,.55); white-space: normal;
}
.tce-unlock-table tr:last-child th[scope="row"] { border-bottom: none; }
.tce-unlock-table thead th { white-space: normal; }
.tce-unlock-table td { white-space: normal; color: #cbd5e1; }
.tce-illus { margin: 0 0 28px; padding: 18px; border: 1px dashed rgba(148,163,184,.45); border-radius: 16px; scroll-margin-top: 84px; }
.tce-illus-tag {
  display: inline-block; margin: 6px 0 10px; padding: 3px 10px; border-radius: 99px;
  border: 1px solid rgba(245,158,11,.4); background: rgba(245,158,11,.1); color: #fbbf24;
  font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.tce-export-note { font-size: .75rem; color: #fca5a5; }
.tce-paused { margin: 0 0 18px; }
@media (max-width: 640px) {
  .tce-illus { padding: 12px; }
  /* Keep stock, trend and rule fit inside a phone's first screen; the rest scrolls sideways. */
  .tce-sample-table tbody th[scope="row"] .tick-sub { white-space: normal; max-width: 92px; }
  .tce-sample-table .cf-bar { display: none; }
}
