*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d26;
  --surface-2: #22263a;
  --border:    #2a2e42;
  --text:      #e2e8f0;
  --muted:     #8892a4;
  --accent:    #4f70f5;
  --green:     #22c55e;
  --red:       #ef4444;
  --amber:     #f59e0b;
  --r:         6px;
  --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono:      "Consolas", "Courier New", monospace;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Nav ─────────────────────────────────────────────── */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 52px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  letter-spacing: -0.02em;
}

.nav-links { display: flex; gap: 2px; flex: 1; }

.nav-link {
  padding: 6px 12px;
  border-radius: var(--r);
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  transition: color .12s, background .12s;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--text); background: var(--surface-2); font-weight: 500; }

.nav-right { display: flex; align-items: center; gap: 10px; }

/* ── Main ────────────────────────────────────────────── */
.main { max-width: 1320px; margin: 0 auto; padding: 28px 24px; }

/* ── Page header ─────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 20px; font-weight: 600; }
.proxy-status { display: flex; align-items: center; gap: 10px; margin-left: auto; font-size: 13px; }

/* ── Stats ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px 22px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-value { font-size: 34px; font-weight: 700; line-height: 1; }

.stat-highlight .stat-value { color: var(--green); }
.stat-alert .stat-value     { color: var(--amber); }

/* ── Section ─────────────────────────────────────────── */
.section { margin-bottom: 32px; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.section-header h2 { font-size: 15px; font-weight: 600; }

/* ── Card ────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px 22px;
  margin-bottom: 24px;
}
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 14px; }

/* ── Table ───────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.table th {
  background: var(--surface-2);
  padding: 9px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover > td { background: rgba(255,255,255,.025); }

.table-sm th, .table-sm td { padding: 7px 12px; }

.row-unseen > td { background: rgba(79, 112, 245, .04); }
.row-unseen > td:first-child { border-left: 3px solid var(--accent); padding-left: 11px; }

/* ── Product row specifics ───────────────────────────── */
.thumb {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 4px;
  display: block;
}

.product-title { font-weight: 500; line-height: 1.3; }
.asin-label    { font-size: 11px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }
.price         { font-weight: 600; color: var(--green); }

.ph-row > td {
  background: var(--bg) !important;
  padding: 0 !important;
}
.ph-inner {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

/* ── Product detail panels (price + BSR history) ─────── */
.detail-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 760px) {
  .detail-panels { grid-template-columns: 1fr; }
}
.detail-panel-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ── BSR display ─────────────────────────────────────── */
.bsr-rank     { font-weight: 600; font-size: 13px; }
.bsr-category { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.3; }

/* ── Filter / Form ───────────────────────────────────── */
.filter-bar  { margin-bottom: 16px; }
.form-row    { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 7px 12px;
  outline: none;
  transition: border-color .12s;
}
.input:focus  { border-color: var(--accent); }
.input-sm     { padding: 5px 10px; font-size: 13px; }
.input option { background: var(--surface); }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  background: var(--accent);
  border: none;
  border-radius: var(--r);
  color: #fff;
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: opacity .12s;
}
.btn:hover { opacity: .82; }

.btn-sm   { padding: 5px 10px; font-size: 12px; }
.btn-xs   { padding: 3px 8px;  font-size: 11px; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); background: var(--surface-2); opacity: 1; }

.btn-danger { background: var(--red); }

/* ── Tags ────────────────────────────────────────────── */
.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  display: inline-block;
  white-space: nowrap;
}
.tag-new         { background: rgba(34,197,94,.15);    color: var(--green); }
.tag-drop        { background: rgba(34,197,94,.15);    color: var(--green); }
.tag-rise        { background: rgba(239,68,68,.12);    color: var(--red);   }
.tag-bsr-up      { background: rgba(34,197,94,.15);    color: var(--green); }
.tag-bsr-down    { background: rgba(239,68,68,.12);    color: var(--red);   }
.tag-new-listing { background: rgba(245,158,11,.18);   color: var(--amber); font-weight: 700; }
.tag-active      { background: rgba(34,197,94,.15);    color: var(--green); }
.tag-inactive    { background: rgba(139,146,164,.12);  color: var(--muted); }

/* ── Badge ───────────────────────────────────────────── */
.badge {
  background: var(--red);
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  padding: 2px 6px;
  text-align: center;
}

/* ── Alert panel (mirrors sys-console, bottom-right) ─── */
#alert-panel {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 380px;
  background: #0d1117;
  border: 1px solid #2a2e42;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,.55);
  font-family: var(--mono);
  font-size: 11px;
  z-index: 300;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(calc(100% + 24px));
  opacity: 0;
  transition: transform .22s ease, opacity .18s ease;
  pointer-events: none;
}
#alert-panel.ap-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}
#alert-panel.ap-fading {
  animation: sc-fadeout 1.3s ease forwards;
}

.ap-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px 7px 12px;
  background: #161b22;
  border-bottom: 1px solid #2a2e42;
  user-select: none;
  flex-shrink: 0;
}
.ap-hdr-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #4a5568;
}
.ap-badge {
  background: #1e2a1e;
  color: var(--green);
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  display: none;
}
.ap-badge.ap-badge-visible { display: inline; }
.ap-hdr-btn {
  background: none;
  border: none;
  color: #3d4455;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0 3px;
  transition: color .1s;
}
.ap-hdr-btn:hover { color: #8b8fa8; }

.ap-log {
  padding: 6px 0;
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.ap-log::-webkit-scrollbar { width: 4px; }
.ap-log::-webkit-scrollbar-track { background: transparent; }
.ap-log::-webkit-scrollbar-thumb { background: #2a2e42; border-radius: 2px; }

.ap-row {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 6px;
  padding: 3px 12px;
  line-height: 1.5;
  transition: opacity .35s;
}
.ap-row.ap-out { opacity: 0; }
.ap-row-ts  { color: #2d3348; white-space: nowrap; }
.ap-row-body { overflow: hidden; }
.ap-row-type { font-weight: 700; }
.ap-row-type.c-green { color: var(--green); }
.ap-row-type.c-amber { color: var(--amber); }
.ap-row-type.c-red   { color: var(--red);   }
.ap-row-name { color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-row-name a { color: #9ca3b8; text-decoration: none; }
.ap-row-name a:hover { color: var(--accent); text-decoration: underline; }
.ap-row-detail { color: #4a5568; font-size: 10px; }

/* ── Utility ─────────────────────────────────────────── */
.text-muted  { color: var(--muted); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red);   }
.text-amber  { color: var(--amber); font-weight: 600; }

.link-subtle { color: var(--text); text-decoration: none; }
.link-subtle:hover { color: var(--accent); }

.actions { display: flex; gap: 6px; align-items: center; white-space: nowrap; }

.empty-state {
  text-align: center;
  padding: 52px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
}

code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--muted);
}

/* ── Pagination ──────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 4px;
}

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

.page-controls { display: flex; align-items: center; gap: 6px; }

.page-num {
  font-size: 13px;
  color: var(--muted);
  padding: 0 8px;
  white-space: nowrap;
}

.btn[disabled] {
  opacity: .3;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── System console ──────────────────────────────────── */
#sys-console {
  position: fixed;
  bottom: 16px;
  left: 16px;
  width: 340px;
  background: #0d1117;
  border: 1px solid #2a2e42;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,.55);
  font-family: var(--mono);
  font-size: 11px;
  z-index: 300;
  overflow: hidden;
  /* Docked and MINIMIZED by default — click the header to expand (.sc-open). */
  transition: transform .22s ease, opacity .18s ease;
}

/* minimized = header bar only; expanded reveals the log */
#sys-console .sc-log { display: none; }
#sys-console.sc-open .sc-log { display: block; }
.sc-caret { margin-left: 6px; color: #3d4455; font-size: 9px; transition: transform .15s; }
#sys-console.sc-open .sc-caret { transform: rotate(180deg); }

/* muted alert panel collapses to just its header bar */
#alert-panel.ap-muted {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}
#alert-panel.ap-muted .ap-log { display: none; }

.sc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px 7px 12px;
  background: #161b22;
  border-bottom: 1px solid #2a2e42;
  user-select: none;
}

.sc-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #4a5568;
}

.sc-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: none;
  flex-shrink: 0;
  animation: sc-pulse 1.2s ease-in-out infinite;
}
.sc-dot-green  { display: block; background: var(--green); }
.sc-dot-amber  { display: block; background: var(--amber); }

@keyframes sc-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .35; transform: scale(.7); }
}

.sc-close {
  background: none;
  border: none;
  color: #3d4455;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  transition: color .1s;
}
.sc-close:hover { color: #8b8fa8; }

.sc-log {
  padding: 8px 0;
  max-height: 220px;
  overflow-y: auto;
}

/* custom scrollbar inside the console */
.sc-log::-webkit-scrollbar { width: 4px; }
.sc-log::-webkit-scrollbar-track { background: transparent; }
.sc-log::-webkit-scrollbar-thumb { background: #2a2e42; border-radius: 2px; }

.sc-line {
  display: flex;
  gap: 8px;
  padding: 2px 12px;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
}
.sc-ts  { color: #2d3348; flex-shrink: 0; }
.sc-msg { color: #6b7280; overflow: hidden; text-overflow: ellipsis; }

.sc-line.sc-info    .sc-msg { color: #9ca3b8; }
.sc-line.sc-success .sc-msg { color: #22c55e; }
.sc-line.sc-warn    .sc-msg { color: #f59e0b; }
.sc-line.sc-dim     .sc-msg { color: #4a5568; }

.sc-line.sc-sep {
  border-top: 1px solid #1e2233;
  margin: 3px 12px;
  padding: 0;
}

#sys-console.sc-fading {
  animation: sc-fadeout 1.3s ease forwards;
}

@keyframes sc-fadeout {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .4; transform: scale(.75); }
}

/* ── Alerts grid (side-by-side on dashboard) ─────────── */
.alerts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 32px;
}
.alerts-grid .section {
  margin-bottom: 0;
  min-width: 0;
}
.alerts-scroll {
  height: 380px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.alerts-scroll::-webkit-scrollbar { width: 4px; }
.alerts-scroll::-webkit-scrollbar-track { background: transparent; }
.alerts-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.alerts-scroll .table {
  border: none;
  border-radius: 0;
}
.alerts-scroll .table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  box-shadow: 0 1px 0 var(--border);
  border-bottom: none;
}
@media (max-width: 900px) {
  .alerts-grid { grid-template-columns: 1fr; }
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .main { padding: 16px; }
  #alert-panel { width: calc(100vw - 32px); right: 16px; }
}

/* ── Summary bar (dashboard top) ────────────────────────── */
.summary-bar {
  display: grid;
  grid-template-columns: 5fr 4fr 3fr;
  gap: 14px;
  margin-bottom: 28px;
}

.summary-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.summary-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  flex-shrink: 0;
  width: 46px;
}

.summary-stats {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.ss-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px;
  min-width: 0;
}
.ss-item:first-child { padding-left: 0; }

.ss-val {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
.ss-val a { color: inherit; text-decoration: none; }
.ss-val a:hover { color: var(--accent); }

.ss-key {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

.ss-div {
  width: 1px;
  height: 28px;
  background: var(--border);
  flex-shrink: 0;
}

.ss-green .ss-val { color: var(--green); }
.ss-amber .ss-val { color: var(--amber); }

.summary-action { flex-shrink: 0; margin-left: auto; }

@media (max-width: 900px) {
  .summary-bar { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .summary-bar { grid-template-columns: 1fr; }
  .summary-section { flex-wrap: wrap; gap: 12px; }
  .summary-stats { flex-wrap: wrap; gap: 4px; }
  .ss-item { align-items: flex-start; padding: 6px 12px 6px 0; }
  .ss-div { display: none; }
}

/* ── Table scroll wrapper ─────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r);
}
.alerts-scroll { overflow-x: auto; }

/* ── Hamburger button ────────────────────────────────── */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  margin-left: 8px;
  border-radius: var(--r);
}
.nav-hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--muted);
  border-radius: 1px;
  transition: transform .2s, opacity .2s;
}
.nav-hamburger.nav-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.nav-open span:nth-child(2) { opacity: 0; }
.nav-hamburger.nav-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Mobile nav ──────────────────────────────────────── */
.nav-mobile-only { display: none; }

@media (max-width: 700px) {
  .nav { flex-wrap: wrap; height: auto; min-height: 52px; padding: 0 16px; }
  .nav-brand { line-height: 52px; }
  .nav-hamburger { display: flex; }
  .nav-right { height: 52px; }
  .nav-action { display: none !important; }

  .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    order: 3;
    border-top: 1px solid var(--border);
    padding: 8px 0 12px;
  }
  .nav-links.nav-open { display: flex; }
  .nav-link { padding: 10px 16px; font-size: 14px; }

  .nav-mobile-only {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px 0;
    margin-top: 4px;
    border-top: 1px solid var(--border);
  }
  .nav-mobile-only .btn { width: 100%; justify-content: center; }
}

/* ── Mobile floating panels ──────────────────────────── */
@media (max-width: 640px) {
  #sys-console { width: calc(100vw - 24px); left: 12px; }
  #alert-panel { width: calc(100vw - 24px); right: 12px; }
}

/* ── Monitoring page ─────────────────────────────────────────────────── */
.mon-range { display: flex; gap: 6px; }

.mon-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 900px) { .mon-cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .mon-cards { grid-template-columns: 1fr; } }

.mon-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 20px;
}
.mon-card-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.mon-card-value { font-size: 28px; font-weight: 600; line-height: 1; margin-bottom: 4px; }
.mon-card-sub   { font-size: 12px; color: var(--muted); margin-bottom: 10px; }

.mon-bar-wrap { background: var(--border); border-radius: 3px; height: 5px; overflow: hidden; }
.mon-bar      { height: 100%; border-radius: 3px; background: var(--accent); transition: width .4s; }
.mon-bar-amber { background: #f59e0b; }
.mon-bar-red   { background: #ef4444; }

.mon-charts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 700px) { .mon-charts { grid-template-columns: 1fr; } }

.badge-green { background: #064e3b; color: #6ee7b7; }

.card-header { margin-bottom: 14px; }
.muted { color: var(--muted); }

/* ── Opportunities page ─────────────────────────────────────────────────────── */
.page-hdr {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.page-sub   { font-size: 13px; color: var(--muted); }

.opp-info-badge {
  font-size: 12px;
  background: #1c1a0e;
  color: var(--amber);
  border: 1px solid #3d350a;
  border-radius: var(--r);
  padding: 6px 12px;
  line-height: 1.4;
  max-width: 380px;
}

.opp-section { margin-bottom: 40px; }
.opp-section-hdr { margin-bottom: 14px; }
.opp-section-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.opp-section-sub   { font-size: 12px; color: var(--muted); }

.opp-empty {
  padding: 32px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 13px;
}

/* Table shell */
.opp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.opp-table th {
  padding: 8px 12px;
  text-align: left;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
}
.opp-table td { padding: 7px 12px; border-bottom: 1px solid var(--border); }
.opp-table a  { color: inherit; text-decoration: none; }
.opp-table a:hover { text-decoration: underline; }

.opp-col-product { width: 220px; }
.opp-col-pack    { width: 80px; white-space: nowrap; }
.opp-col-ours    { width: 110px; }
.opp-col-comp    { width: 140px; }

/* Group header rows */
.opp-group {
  background: var(--surface);
  cursor: pointer;
  user-select: none;
}
.opp-group:hover { background: var(--surface-2); }

.opp-group-name {
  font-weight: 600;
  padding: 10px 12px;
}
.opp-arrow {
  display: inline-block;
  width: 16px;
  font-size: 10px;
  color: var(--muted);
  transition: transform .15s;
}
.opp-group-meta {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}
.opp-group-sum {
  font-size: 12px;
  color: var(--muted);
  padding: 10px 12px;
}
.opp-our-sum { color: var(--text); }
.opp-comp-best { color: var(--amber); font-weight: 600; }

/* Summary badges in group header */
.opp-badge-red   { color: var(--red);   font-weight: 600; }
.opp-badge-muted { color: var(--muted); }
.opp-badge-amber { color: var(--amber); font-weight: 600; }

/* Pack sub-rows */
.opp-pack { background: var(--bg); }
.opp-pack:hover { background: #12141e; }

.opp-pack-indent { width: 18px; }
.opp-pack-size {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

/* Our cell */
.opp-our { font-weight: 600; }

/* Competitor cells */
.opp-comp-cell { }

/* Cell states */
.opp-cell-winning { color: var(--green); }
.opp-cell-losing  { color: var(--red); }
.opp-cell-threat  { color: var(--amber); font-weight: 600; }
.opp-cell-ok      { color: var(--muted); font-size: 12px; }
.opp-cell-none    { color: var(--border); }
.opp-cell-missing { color: var(--muted); font-style: italic; font-size: 11px; }

@media (max-width: 700px) {
  .opp-col-comp { display: none; }
  .opp-col-comp:nth-child(4) { display: table-cell; } /* show first competitor only */
}

/* Opportunities page — tabs + toolbar */
.opp-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.opp-tab { padding: 8px 16px; border-radius: var(--r) var(--r) 0 0; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 500; border: 1px solid transparent; border-bottom: none; transition: color .12s, background .12s; }
.opp-tab:hover { color: var(--text); background: var(--surface); }
.opp-tab-active { color: var(--text); background: var(--surface); border-color: var(--border); margin-bottom: -1px; }

.opp-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.opp-search { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); color: var(--text); padding: 6px 12px; font-size: 13px; width: 220px; }
.opp-search:focus { outline: none; border-color: var(--accent); }
.opp-sort-group { display: flex; gap: 4px; flex-wrap: wrap; }
.sort-btn { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); color: var(--muted); padding: 5px 11px; font-size: 12px; cursor: pointer; transition: color .1s, background .1s, border-color .1s; }
.sort-btn:hover { color: var(--text); background: var(--surface-2); }
.sort-btn.active { color: var(--text); background: var(--surface-2); border-color: var(--accent); }

/* Opportunities table — new scalable layout */
.opp-col-product { width: 200px; min-width: 160px; }
.opp-col-pack    { width: 72px; white-space: nowrap; }
.opp-col-ours    { width: 100px; }
.opp-col-best    { width: 180px; }
.opp-col-gap     { width: 70px; text-align: right; }
.opp-col-others  { min-width: 180px; }

.opp-others { font-size: 11px; color: var(--muted); }
.opp-others-item { white-space: nowrap; margin-right: 8px; }

.opp-group-sum-gap { font-weight: 700; }
.opp-cell-gap-lose { color: var(--red); font-weight: 700; }
.opp-cell-gap-win  { color: var(--green); font-weight: 600; }

/* Active state for ghost buttons used as sort toggles */
.btn-ghost.active { color: var(--accent); border-color: var(--accent); background: var(--surface-2); opacity: 1; }

/* ── Modal overlay ─────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.modal-open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 28px 28px 24px;
  min-width: 340px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: modal-in .15s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-title  { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.modal-sub    { font-size: 12px; color: var(--muted); margin-bottom: 18px; }
.modal-label  { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Product-type badges (capsules / drops / gummies) ─────────────── */
.type-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  vertical-align: middle;
  margin-left: 6px;
  border: 1px solid transparent;
  line-height: 1.5;
}
.type-capsules { background: rgba(79, 112, 245, 0.12); color: #8aa8ff; border-color: rgba(79, 112, 245, 0.35); }
.type-drops    { background: rgba(168, 85, 247, 0.12); color: #c4a4ff; border-color: rgba(168, 85, 247, 0.35); }
.type-gummies  { background: rgba(245, 158, 11, 0.12); color: #ffc870; border-color: rgba(245, 158, 11, 0.35); }


/* ── Daily Report ─────────────────────────────────────────────────── */
.rpt-section {
  margin: 24px 0 10px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.rpt-good { color: var(--green); font-weight: 600; }
.rpt-bad  { color: var(--red);   font-weight: 600; }
.rpt-merchant { margin-top: 12px; }

/* Variant suffix on missed-products listing — distinguishes capsules/gummies/drops
   variants of the same product line ("Healthy Flow — Gummies" vs the capsules group). */
.opp-variant {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.92em;
  margin-left: 4px;
}

/* ── Product launch form ──────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field-hint { font-size: 11px; color: var(--muted); margin-top: 2px; }
.ingredient-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px;
}
.ingredient-chip {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; padding: 5px 8px;
  border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer;
}
.ingredient-chip input { margin: 0; }

/* ── Price match (pricing matrix Match mode + beat competitor picker) ── */
.comp-open-icon { display:none; font-size:11px; margin-left:4px; color:var(--muted); text-decoration:none; }
.match-on .comp-open-icon { display:inline; }
.match-on .match-cell { cursor:pointer; }
.match-on .match-cell:hover { outline:1px solid var(--accent); outline-offset:-1px; }
.match-on td.opp-cell-selected { outline:2px solid var(--accent); outline-offset:-2px; background:rgba(79,112,245,.16); }
.match-tray {
  position:sticky; bottom:0; z-index:40; display:none; align-items:center; gap:12px;
  margin-top:16px; padding:10px 16px;
  background:var(--surface-2); border:1px solid var(--accent); border-radius:var(--r);
  box-shadow:0 -6px 20px rgba(0,0,0,.35);
}
.match-tray-hint { color:var(--muted); font-size:13px; }
.match-count { font-weight:600; margin-left:auto; }
.comp-choice {
  display:inline-flex; align-items:center; gap:5px; font-size:13px;
  margin:2px 10px 2px 0; padding:3px 8px; border:1px solid var(--border); border-radius:6px; cursor:pointer;
}
.comp-choice input { margin:0; }
.beat-comp-row td { background:rgba(255,255,255,.02); }

/* ── Report upload (admin/reports) ───────────────────────────── */
.banner { padding:.6rem .9rem; border-radius:6px; margin:.8rem 0; font-size:.9rem; }
.banner-ok  { background:#0f2e1a; color:#7ee2a8; border:1px solid #1f5c38; }
.banner-err { background:#33161a; color:#f1a3ad; border:1px solid #6c2630; }
.dropzone { border:2px dashed #3a4252; border-radius:8px; padding:1.4rem; text-align:center;
            background:#1a1f29; transition:border-color .15s, background .15s; position:relative; }
.dropzone-hot { border-color:#4f8cff; background:#1d2533; }
.dropzone input[type=file] { position:absolute; inset:0; opacity:0; cursor:pointer; width:100%; height:100%; }
.dropzone-label { display:block; pointer-events:none; }
.dropzone-label span { display:block; margin-top:.3rem; font-size:.82rem; }

/* ── FBA candidates ───────────────────────────────────────────── */
.opp-table td.num, .opp-table th.num { text-align:right; white-space:nowrap; }
.fba-summary { display:flex; align-items:center; gap:.5rem; margin:.8rem 0; flex-wrap:wrap; }
.fba-chip { padding:.25rem .7rem; border-radius:14px; font-size:.8rem; font-weight:600; }
.tier-badge { display:inline-block; padding:.12rem .55rem; border-radius:10px; font-size:.72rem;
              font-weight:700; text-transform:uppercase; letter-spacing:.03em; }
.tier-high,  .fba-chip.tier-high  { background:#0f2e1a; color:#7ee2a8; border:1px solid #1f5c38; }
.tier-medium,.fba-chip.tier-medium{ background:#33270f; color:#f1cf8a; border:1px solid #6c521f; }
.tier-low,   .fba-chip.tier-low   { background:#23272f; color:#9aa3b2; border:1px solid #3a4252; }
.fba-title { font-weight:600; }
.fba-rec { color:#7ee2a8; font-size:1.02rem; }
.trend-up   { color:#7ee2a8; font-weight:600; }
.trend-down { color:#f1a3ad; font-weight:600; }

/* ── Secondary tab bar (consolidated nav groups) ──────────────── */
.subnav {
  position: sticky;
  top: 52px;
  z-index: 99;
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 8px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.subnav-tab {
  padding: 5px 14px;
  border-radius: var(--r);
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: color .12s, background .12s;
}
.subnav-tab:hover { color: var(--text); background: var(--surface-2); }
.subnav-tab.subnav-active { color: var(--text); background: var(--surface-2); }

/* Opportunities pagination control */
.opp-pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 18px 0 4px; }

/* ── SFR: position badges + detail modal ─────────────────────── */
.pos-badge { display:inline-block; padding:.05rem .4rem; border-radius:9px; font-size:.7rem; font-weight:700; }
.pos-1 { background:#0f2e1a; color:#7ee2a8; border:1px solid #1f5c38; }
.pos-2 { background:#16243a; color:#8fb6f1; border:1px solid #274266; }
.pos-3 { background:#23272f; color:#9aa3b2; border:1px solid #3a4252; }
.spark { vertical-align:middle; }
.sfr-row:hover > td { background: rgba(255,255,255,.03); }
.sfr-overlay { position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:500; display:none;
               align-items:flex-start; justify-content:center; padding:5vh 16px; overflow:auto; }
.sfr-overlay.open { display:flex; }
.sfr-modal { background:#0d1117; border:1px solid #2a2e42; border-radius:10px; width:100%;
             max-width:880px; box-shadow:0 12px 48px rgba(0,0,0,.6); }
.sfr-modal-hd { display:flex; align-items:flex-start; justify-content:space-between;
                padding:14px 18px; border-bottom:1px solid #2a2e42; }
.sfr-m-title { font-size:15px; font-weight:600; }
.sfr-m-title a { color:inherit; text-decoration:none; }
.sfr-modal-bd { padding:14px 18px; max-height:70vh; overflow:auto; }
.sfr-term-tbl { font-size:12px; }

/* Sparkline hover tooltip */
.spark-pt { cursor: pointer; }
.spark-tip { position: fixed; z-index: 600; display: none; pointer-events: none;
  background: #0d1117; border: 1px solid #2a2e42; border-radius: 5px; padding: 3px 8px;
  font-size: 11px; font-family: var(--mono); white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.5); }
.spark-tip strong { color: #e2e8f0; }
.spark-tip span { color: #8892a4; margin-left: 7px; }

/* ── Long Tail KW (SQP Brand View) ─────────────────────────────────────── */
.ltkw-stats { display:flex; gap:12px; flex-wrap:wrap; margin:.4rem 0 1rem; }
.ltkw-stat { background:var(--surface); border:1px solid var(--border); border-radius:8px;
  padding:.7rem 1rem; min-width:120px; }
.ltkw-stat-hero { border-color:rgba(241,163,173,.4); background:rgba(108,38,48,.18); }
.ltkw-stat-n { font-size:1.5rem; font-weight:700; line-height:1.1; }
.ltkw-stat-hero .ltkw-stat-n { color:#f1a3ad; }
.ltkw-stat-l { font-size:11px; color:var(--muted); margin-top:2px; }
.bkt-fg-invisible  { color:#c79bff; }
.bkt-fg-conversion { color:#f1a3ad; }
.bkt-fg-price      { color:#f5c469; }
.bkt-fg-winning    { color:#7ee2a8; }

.ltkw-filters { display:flex; flex-direction:column; gap:8px; margin-bottom:1rem; }
.ltkw-frow { display:flex; gap:6px; align-items:center; flex-wrap:wrap; }
.ltkw-flabel { font-size:11px; text-transform:uppercase; letter-spacing:.04em;
  color:var(--muted); margin-right:4px; }
.chip { display:inline-flex; align-items:center; gap:5px; padding:4px 10px; font-size:12px;
  border-radius:999px; border:1px solid var(--border); background:var(--surface);
  color:var(--muted); text-decoration:none; cursor:pointer; white-space:nowrap; }
.chip:hover { color:var(--text); border-color:var(--accent); }
.chip-on { background:var(--surface-2); color:var(--text); border-color:var(--accent); font-weight:600; }
.chip-ct { font-size:10px; background:rgba(255,255,255,.07); border-radius:8px; padding:0 5px; }
.ltkw-search { background:var(--bg); border:1px solid var(--border); border-radius:6px;
  color:var(--text); padding:4px 9px; font-size:12px; min-width:150px; }

.ltkw-table td { vertical-align:top; }
.ltkw-q { font-weight:600; }
.ltkw-link { font-size:11px; margin-top:2px; }
.ltkw-link a { color:var(--muted); }
.ltkw-link a:hover { color:var(--text); }
.ltkw-sfr { margin-left:6px; color:var(--accent) !important; }
.ltkw-price { font-family:var(--mono); font-size:12px; }
.ltkw-new { display:inline-block; font-size:10px; font-weight:600; padding:1px 6px; border-radius:999px;
  background:rgba(126,226,168,.14); color:#7ee2a8; border:1px solid rgba(126,226,168,.34);
  text-transform:uppercase; letter-spacing:.03em; }

/* group-expansion affordance + landscape sub-table */
.exp-btn { background:none; border:none; color:var(--muted); cursor:pointer; font-size:10px;
  padding:0 5px 0 0; line-height:1; transition:transform .12s ease; display:inline-block; }
.exp-btn:hover { color:var(--accent); }
.exp-open .exp-btn { transform:rotate(90deg); color:var(--accent); }
.ltkw-grp { display:inline-block; margin-left:8px; font-size:11px; color:var(--accent);
  cursor:pointer; white-space:nowrap; }
.ltkw-grp:hover { text-decoration:underline; }
.ltkw-exp > td { background:var(--bg); padding:0 12px 0 24px; border-bottom:1px solid var(--border); }
.ltkw-exp-bd { padding:.7rem 0; }
.ltkw-exp-hd { font-size:12px; font-weight:600; margin-bottom:.4rem; }
.ltkw-sub { border-collapse:collapse; width:auto; min-width:420px; }
.ltkw-sub th { text-align:left; font-size:10px; text-transform:uppercase; letter-spacing:.04em;
  color:var(--muted); font-weight:600; padding:3px 14px 3px 0; border-bottom:1px solid var(--border); }
.ltkw-sub td { padding:4px 14px 4px 0; font-size:12px; border-bottom:1px solid rgba(42,46,66,.5); }
.ltkw-sub td.num, .ltkw-sub th.num { text-align:right; white-space:nowrap; font-family:var(--mono); }
.ltkw-sub a { color:var(--accent); text-decoration:none; }
.ltkw-sub a:hover { text-decoration:underline; }
.ltkw-sub .sub-ours td { background:rgba(79,112,245,.10); }
.ltkw-you { display:inline-block; font-size:9px; font-weight:700; padding:0 5px; border-radius:999px;
  background:rgba(79,112,245,.18); color:#8aa8ff; text-transform:uppercase; letter-spacing:.03em; }

/* funnel mini-bars (brand share at I→C→P) */
.fnl { display:flex; flex-direction:column; gap:2px; min-width:170px; }
.fnl-row { display:flex; align-items:center; gap:6px; }
.fnl-k { width:12px; font-size:10px; color:var(--muted); font-family:var(--mono); }
.fnl-track { flex:1; height:9px; background:var(--bg); border-radius:4px; overflow:hidden; }
.fnl-bar { display:block; height:100%; border-radius:4px; }
.fnl-I { background:#3a4a7a; }
.fnl-C { background:#4f70f5; }
.fnl-P { background:#7ee2a8; }
.fnl-v { width:34px; text-align:right; font-size:11px; font-family:var(--mono); color:var(--muted); }

/* issue badges */
.bkt { display:inline-block; padding:2px 9px; border-radius:999px; font-size:11px; font-weight:600;
  white-space:nowrap; border:1px solid transparent; }
.bkt-invisible  { background:rgba(199,155,255,.13); color:#c79bff; border-color:rgba(199,155,255,.32); }
.bkt-conversion { background:rgba(241,163,173,.13); color:#f1a3ad; border-color:rgba(241,163,173,.32); }
.bkt-price      { background:rgba(245,196,105,.13); color:#f5c469; border-color:rgba(245,196,105,.32); }
.bkt-winning    { background:rgba(126,226,168,.13); color:#7ee2a8; border-color:rgba(126,226,168,.32); }
.bkt-building   { background:var(--surface-2); color:var(--muted); border-color:var(--border); }
.bkt-no_sales   { background:transparent; color:var(--muted); border-color:var(--border); }
.chip-invisible.chip-on  { border-color:#c79bff; }
.chip-conversion.chip-on { border-color:#f1a3ad; }
.chip-price.chip-on      { border-color:#f5c469; }
.chip-winning.chip-on    { border-color:#7ee2a8; }

/* SFR row pinned via ?focus= deep-link from Keyword Opportunities */
.sfr-focus > td { background:rgba(79,112,245,.12); }
.sfr-focus > td:first-child { border-left:3px solid var(--accent); padding-left:9px; }

/* Sales Estimator (Helium-10-X-Ray-style) */
.se-frow { display:flex; flex-wrap:wrap; align-items:center; gap:6px; margin-bottom:10px; }
.se-flabel { font-size:11px; text-transform:uppercase; letter-spacing:.04em; color:var(--text-muted,#8a93a6); }
.se-table td, .se-table th { white-space:nowrap; }
.se-table td:first-child { white-space:normal; max-width:520px; }
.se-conf { display:inline-block; font-size:11px; font-weight:600; padding:1px 7px; border-radius:10px; text-transform:capitalize; }
.se-conf-high { background:rgba(126,226,168,.16); color:#7ee2a8; }
.se-conf-med  { background:rgba(245,196,105,.16); color:#f5c469; }
.se-conf-low  { background:rgba(241,163,173,.16); color:#f1a3ad; }
/* "Our comparable pack" columns — visually set off from the competitor columns */
.se-table th.se-ours, .se-table td.se-ours { border-left:2px solid rgba(79,112,245,.45); }
.se-table td.se-ours a { color:var(--accent); text-decoration:none; }
.se-table td.se-ours a:hover { text-decoration:underline; }
/* By Product Group: group header + pack sub-rows */
.se-grp-hdr { cursor:pointer; }
.se-grp-hdr:hover td { background:rgba(79,112,245,.06); }
.se-caret { display:inline-block; width:13px; color:var(--accent); font-size:11px; }
.se-grp-pack td { background:rgba(255,255,255,.015); font-size:12.5px; }
.se-pack-cell { padding-left:30px !important; color:var(--text-muted,#8a93a6); }
.se-hidden { display:none; }
/* "you" marker for Ideal Performance (shown alongside competitors for benchmarking) */
.se-you { display:inline-block; font-size:10px; font-weight:700; text-transform:uppercase;
  letter-spacing:.04em; padding:1px 6px; border-radius:9px; background:rgba(79,112,245,.18);
  color:var(--accent); vertical-align:middle; }
.se-you-row > td { background:rgba(79,112,245,.06); }

/* ── Google keyword data (Keywords Everywhere) ─────────────────────────────── */
.gkw-status { font-size:12px; margin-top:.35rem; }
.gkw-status form { margin:0; }
.gkw-cell { white-space:nowrap; }
.gkw-cell .gspark { display:block; margin-left:auto; margin-top:2px; opacity:.9; }
.gspark { vertical-align:middle; }
/* Google Demand page */
.gd-seed { display:flex; gap:8px; align-items:center; margin:.4rem 0 .9rem; flex-wrap:wrap; }
.gd-seed input[type=search] { min-width:260px; }
.gd-ideas td { background:rgba(255,255,255,.015); font-size:12.5px; }
.gd-src { display:inline-block; font-size:10px; font-weight:700; text-transform:uppercase;
  letter-spacing:.04em; padding:1px 6px; border-radius:9px; vertical-align:middle; }
.gd-src-related { background:rgba(79,112,245,.18); color:var(--accent); }
.gd-src-pasf { background:rgba(245,196,105,.16); color:#f5c469; }
.gd-src-seed { background:rgba(126,226,168,.16); color:#7ee2a8; }
.gd-amz { display:inline-block; font-size:10px; font-weight:700; padding:1px 6px;
  border-radius:9px; background:rgba(126,226,168,.16); color:#7ee2a8; }
.gd-ideas-bd { padding:8px 6px 10px 26px; }
.gd-ideas-hd { font-weight:600; margin-bottom:4px; }
.gd-mine-note { font-size:11.5px; color:var(--text-muted,#8a93a6); margin-top:4px; }
