/* LVIN Competitive Intelligence — Stylesheet */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f4f1;
  --bg2: #ffffff;
  --bg3: #eeedea;
  --border: #e0deda;
  --border2: #cccac5;
  --text: #1a1a18;
  --text2: #5a5955;
  --text3: #9a9890;
  --blue: #1a5fb4;
  --blue-bg: #e8f0fc;
  --blue-text: #1a4a8a;
  --green: #2d7d46;
  --green-bg: #e8f5ec;
  --green-text: #1e5c32;
  --red: #c0392b;
  --red-bg: #fdecea;
  --red-text: #922b21;
  --amber: #b45309;
  --amber-bg: #fef3e2;
  --amber-text: #924208;
  --purple: #6d3fa0;
  --purple-bg: #f3eefa;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-lg: 12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'SF Mono', 'Consolas', monospace;
}

body { font-family: var(--font); background: var(--bg); color: var(--text);
  font-size: 13px; line-height: 1.5; -webkit-font-smoothing: antialiased; }

.hidden { display: none !important; }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center;
  justify-content: center; background: var(--bg); }
.login-card { background: var(--bg2); border: 0.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px; width: 360px;
  box-shadow: var(--shadow-lg); }
.login-logo { font-size: 22px; font-weight: 700; color: var(--text);
  letter-spacing: -0.5px; margin-bottom: 4px; }
.login-logo span { color: var(--blue); }
.login-sub { color: var(--text3); font-size: 12px; margin-bottom: 28px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 500;
  color: var(--text2); margin-bottom: 5px; }
.field input { width: 100%; padding: 9px 12px; border: 0.5px solid var(--border2);
  border-radius: var(--radius); font-size: 13px; background: var(--bg);
  color: var(--text); outline: none; transition: border 0.15s; }
.field input:focus { border-color: var(--blue); background: white; }
.err-msg { color: var(--red); font-size: 12px; margin-bottom: 12px;
  background: var(--red-bg); padding: 8px 10px; border-radius: 6px; }

/* ── Buttons ── */
.btn-primary { background: var(--blue); color: white; border: none;
  padding: 9px 18px; border-radius: var(--radius); font-size: 13px;
  font-weight: 500; cursor: pointer; transition: opacity 0.15s; }
.btn-primary:hover { opacity: 0.88; }
.btn-primary.full { width: 100%; padding: 11px; margin-top: 4px; }
.btn-ghost { background: none; border: 0.5px solid var(--border2);
  color: var(--text2); padding: 6px 14px; border-radius: var(--radius);
  font-size: 12px; cursor: pointer; transition: background 0.15s; }
.btn-ghost:hover { background: var(--bg3); }
.btn-icon { background: none; border: 0.5px solid var(--border);
  width: 30px; height: 30px; border-radius: var(--radius); cursor: pointer;
  font-size: 16px; color: var(--text2); display: inline-flex;
  align-items: center; justify-content: center; transition: background 0.15s; }
.btn-icon:hover { background: var(--bg3); }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 6px; }
.btn-danger { background: var(--red-bg); color: var(--red-text);
  border: 0.5px solid #f5c6c3; }
.btn-success { background: var(--green-bg); color: var(--green-text);
  border: 0.5px solid #b8e0c4; }

/* ── Topbar ── */
.topbar { height: 48px; background: var(--bg2); border-bottom: 0.5px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow); }
.topbar-left { display: flex; align-items: center; gap: 24px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 15px; font-weight: 700; color: var(--text);
  letter-spacing: -0.3px; }
.logo span { color: var(--blue); }
.nav-tabs { display: flex; gap: 2px; }
.nav-tab { background: none; border: none; padding: 6px 14px;
  border-radius: var(--radius); font-size: 13px; color: var(--text2);
  cursor: pointer; transition: all 0.15s; font-weight: 500; }
.nav-tab:hover { background: var(--bg3); color: var(--text); }
.nav-tab.active { background: var(--blue-bg); color: var(--blue-text); }
.alert-badge { background: var(--red); color: white; border-radius: 10px;
  padding: 1px 6px; font-size: 10px; font-weight: 700; margin-left: 4px; }
.alert-badge.zero { display: none; }
.scraper-status { font-size: 11px; color: var(--green); }
.last-run { font-size: 11px; color: var(--text3); }

/* ── Views ── */
.view { padding: 16px; display: none; }
.view.active { display: block; }

/* ── Summary Strip ── */
.summary-strip { display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 10px; margin-bottom: 16px; }
.sum-card { background: var(--bg2); border: 0.5px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; }
.sum-label { font-size: 11px; color: var(--text3); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: 0.04em; }
.sum-val { font-size: 22px; font-weight: 700; color: var(--text);
  line-height: 1; margin-bottom: 2px; }
.sum-sub { font-size: 11px; color: var(--text3); }
.sum-card.green .sum-val { color: var(--green); }
.sum-card.red .sum-val { color: var(--red); }
.sum-card.amber .sum-val { color: var(--amber); }

/* ── Dashboard Layout ── */
.dash-layout { display: flex; gap: 12px; }
.filter-sidebar { width: 192px; min-width: 192px; flex-shrink: 0; }
.filter-panel { background: var(--bg2); border: 0.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px; position: sticky; top: 64px; }
.filter-title { font-size: 10px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.06em; margin: 14px 0 6px;
  padding-bottom: 4px; border-bottom: 0.5px solid var(--border); }
.filter-title:first-child { margin-top: 0; }
.filter-option { display: flex; align-items: center; gap: 7px; padding: 3px 0;
  font-size: 12px; color: var(--text2); cursor: pointer; }
.filter-option input { accent-color: var(--blue); }
.filter-option.active-filter { color: var(--text); font-weight: 500; }
.radio-group { display: flex; flex-direction: column; gap: 4px; }
.radio-group label { display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text2); cursor: pointer; }
.radio-group input[type=radio] { accent-color: var(--blue); }
.filter-apply { margin-top: 14px; width: 100%; }
.price-inputs { display: flex; gap: 6px; margin-top: 6px; }
.price-inputs input { width: 100%; padding: 5px 8px; border: 0.5px solid var(--border2);
  border-radius: 6px; font-size: 11px; background: var(--bg); color: var(--text); }

/* ── Table ── */
.table-wrap { flex: 1; overflow: hidden; }
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  flex-wrap: wrap; }
.search-box { display: flex; align-items: center; gap: 8px;
  background: var(--bg2); border: 0.5px solid var(--border2);
  border-radius: var(--radius); padding: 7px 12px; flex: 1; min-width: 200px; }
.search-box input { border: none; background: none; font-size: 13px;
  color: var(--text); width: 100%; outline: none; }
.search-box input::placeholder { color: var(--text3); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px;
  border-radius: 20px; border: 0.5px solid var(--border2); font-size: 11px;
  color: var(--text2); cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.chip.on { background: var(--blue-bg); color: var(--blue-text);
  border-color: #b8d0f5; }
.sku-count-label { font-size: 11px; color: var(--text3); white-space: nowrap; margin-left: auto; }

.data-table { width: 100%; border-collapse: collapse;
  background: var(--bg2); border: 0.5px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; }
.data-table th { padding: 9px 12px; text-align: left; font-size: 11px;
  font-weight: 600; color: var(--text3); background: var(--bg3);
  border-bottom: 0.5px solid var(--border); white-space: nowrap;
  text-transform: uppercase; letter-spacing: 0.04em; cursor: pointer;
  user-select: none; }
.data-table th:hover { color: var(--text); }
.data-table th .sort-arrow { margin-left: 3px; opacity: 0.4; }
.data-table th.sort-asc .sort-arrow::after { content: ' ▲'; opacity: 1; }
.data-table th.sort-desc .sort-arrow::after { content: ' ▼'; opacity: 1; }
.data-table td { padding: 9px 12px; border-bottom: 0.5px solid var(--border);
  white-space: nowrap; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); cursor: pointer; }
.data-table tr.row-cheaper td { background: rgba(45,125,70,0.04); }
.data-table tr.row-cheaper:hover td { background: rgba(45,125,70,0.08); }
.data-table tr.row-pricier td { background: rgba(192,57,43,0.04); }
.data-table tr.row-pricier:hover td { background: rgba(192,57,43,0.08); }

/* ── Table Cell Components ── */
.brand-cell { display: flex; align-items: center; gap: 8px; }
.brand-avatar { width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; flex-shrink: 0; }
.model-primary { font-weight: 600; font-size: 12px; color: var(--text); }
.model-secondary { font-size: 11px; color: var(--text3); }
.price-cell { font-variant-numeric: tabular-nums; font-size: 12px; }
.price-lvin { font-weight: 700; }
.price-best { font-weight: 700; color: var(--green); }
.price-na { color: var(--text3); }
.offer-tag { display: inline-block; font-size: 10px; padding: 1px 5px;
  border-radius: 4px; background: var(--blue-bg); color: var(--blue-text);
  margin-left: 4px; vertical-align: middle; }
.gap-positive { color: var(--green); font-weight: 600; font-size: 12px; }
.gap-negative { color: var(--red); font-weight: 600; font-size: 12px; }
.gap-neutral { color: var(--text3); font-size: 12px; }
.stock-badge { display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.stock-in { background: var(--green-bg); color: var(--green-text); }
.stock-out { background: var(--red-bg); color: var(--red-text); }
.stock-mixed { background: var(--amber-bg); color: var(--amber-text); }
.stock-unknown { background: var(--bg3); color: var(--text3); }
.time-ago { font-size: 11px; color: var(--text3); }

/* ── Detail Panel ── */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  z-index: 200; }
.detail-panel { position: fixed; top: 0; right: 0; bottom: 0; width: 720px;
  max-width: 95vw; background: var(--bg2); z-index: 201; overflow-y: auto;
  box-shadow: -4px 0 24px rgba(0,0,0,0.15); padding: 24px; }
.detail-close { position: absolute; top: 16px; right: 16px;
  background: var(--bg3); border: none; width: 32px; height: 32px;
  border-radius: 50%; cursor: pointer; font-size: 18px; color: var(--text2);
  display: flex; align-items: center; justify-content: center; }
.detail-close:hover { background: var(--border2); }
.detail-title { font-size: 18px; font-weight: 700; color: var(--text);
  margin-bottom: 2px; padding-right: 40px; }
.detail-sub { font-size: 12px; color: var(--text3); margin-bottom: 20px; }
.section-title { font-size: 11px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.06em; margin: 20px 0 10px;
  padding-bottom: 6px; border-bottom: 0.5px solid var(--border); }

/* Retailer snapshot cards */
.retailer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr));
  gap: 10px; margin-bottom: 4px; }
.retailer-card { border: 0.5px solid var(--border); border-radius: var(--radius);
  padding: 12px; background: var(--bg); }
.retailer-card.best-price { border-color: var(--green); background: var(--green-bg); }
.retailer-name { font-size: 11px; font-weight: 600; color: var(--text2);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.retailer-price-main { font-size: 17px; font-weight: 700; color: var(--text); }
.retailer-price-eff { font-size: 12px; color: var(--green); margin-top: 2px; }
.retailer-mrp { font-size: 11px; color: var(--text3); text-decoration: line-through; }
.retailer-avail { display: inline-block; margin-top: 6px; }
.offer-list { margin-top: 8px; }
.offer-row { display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0; border-top: 0.5px solid var(--border); }
.offer-type-badge { font-size: 10px; padding: 1px 6px; border-radius: 4px;
  font-weight: 500; }
.ot-coupon { background: var(--purple-bg); color: var(--purple); }
.ot-cashback { background: var(--green-bg); color: var(--green-text); }
.ot-credit_card,.ot-debit_card { background: var(--blue-bg); color: var(--blue-text); }
.ot-exchange { background: var(--amber-bg); color: var(--amber-text); }
.ot-emi,.ot-bundle { background: var(--bg3); color: var(--text2); }
.offer-amount { font-weight: 600; font-size: 12px; color: var(--green); }

/* Effective price breakdown */
.eff-breakdown { background: var(--bg3); border-radius: var(--radius);
  padding: 14px; margin-bottom: 4px; }
.eff-row { display: flex; justify-content: space-between; padding: 4px 0;
  font-size: 13px; border-bottom: 0.5px solid var(--border); }
.eff-row:last-child { border-bottom: none; }
.eff-row.total { font-weight: 700; font-size: 15px; color: var(--green); margin-top: 4px; }
.eff-row .deduction { color: var(--red); }

/* History tabs */
.hist-tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.hist-tab { padding: 5px 14px; border-radius: 20px; border: 0.5px solid var(--border2);
  font-size: 12px; cursor: pointer; background: none; color: var(--text2); }
.hist-tab.active { background: var(--blue); color: white; border-color: var(--blue); }

/* Chart placeholder */
.chart-area { height: 220px; background: var(--bg3); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: 12px; position: relative; overflow: hidden; }
.chart-canvas { width: 100%; height: 100%; }

/* ── Alerts View ── */
.alert-list { display: flex; flex-direction: column; gap: 8px; max-width: 860px; }
.alert-item { background: var(--bg2); border: 0.5px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  display: flex; align-items: flex-start; gap: 12px; }
.alert-item.unread { border-left: 3px solid var(--blue); }
.alert-item.severity-critical { border-left-color: var(--red); }
.alert-item.severity-warning { border-left-color: var(--amber); }
.alert-severity { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.sev-critical { background: var(--red); }
.sev-warning { background: var(--amber); }
.sev-info { background: var(--blue); }
.alert-body { flex: 1; }
.alert-product { font-weight: 600; font-size: 13px; color: var(--text); }
.alert-msg { font-size: 12px; color: var(--text2); margin-top: 2px; }
.alert-meta { font-size: 11px; color: var(--text3); margin-top: 4px; }
.alert-change { display: flex; gap: 8px; margin-top: 6px; align-items: center; }
.old-val { font-size: 12px; color: var(--red); text-decoration: line-through; }
.new-val { font-size: 12px; color: var(--green); font-weight: 600; }
.alert-actions { flex-shrink: 0; }

/* ── Analytics ── */
.analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  max-width: 1100px; }
.analytics-card { background: var(--bg2); border: 0.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px; }
.analytics-card.full { grid-column: 1/-1; }
.analytics-title { font-size: 13px; font-weight: 700; color: var(--text);
  margin-bottom: 14px; }
.mover-row { display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0; border-bottom: 0.5px solid var(--border); }
.mover-row:last-child { border-bottom: none; }
.mover-name { font-size: 12px; font-weight: 500; color: var(--text); }
.mover-sub { font-size: 11px; color: var(--text3); }
.mover-change { font-size: 13px; font-weight: 700; }
.change-up { color: var(--red); }
.change-down { color: var(--green); }
.opportunity-row { display: flex; align-items: center; gap: 10px; padding: 7px 0;
  border-bottom: 0.5px solid var(--border); }
.opportunity-row:last-child { border-bottom: none; }
.opp-name { font-size: 12px; font-weight: 500; color: var(--text); flex: 1; }
.opp-lvin { font-size: 12px; color: var(--text2); }
.opp-market { font-size: 12px; color: var(--text2); }
.opp-gap { font-size: 12px; font-weight: 700; padding: 2px 8px;
  border-radius: 10px; }
.opp-raise { background: var(--green-bg); color: var(--green-text); }
.opp-cut { background: var(--red-bg); color: var(--red-text); }
.bar-chart { margin-top: 8px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bar-label { font-size: 12px; color: var(--text2); width: 90px; flex-shrink: 0;
  text-align: right; }
.bar-track { flex: 1; background: var(--bg3); border-radius: 4px; height: 18px;
  overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--blue);
  display: flex; align-items: center; padding-left: 6px;
  font-size: 10px; color: white; font-weight: 600; transition: width 0.6s ease; }

/* ── Admin Panel ── */
.admin-layout { display: grid; grid-template-columns: 180px 1fr; gap: 16px; }
.admin-nav { background: var(--bg2); border: 0.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 10px; height: fit-content;
  position: sticky; top: 64px; }
.admin-nav-item { display: block; padding: 8px 12px; border-radius: var(--radius);
  font-size: 13px; color: var(--text2); cursor: pointer; border: none;
  background: none; width: 100%; text-align: left; transition: all 0.15s; }
.admin-nav-item:hover { background: var(--bg3); color: var(--text); }
.admin-nav-item.active { background: var(--blue-bg); color: var(--blue-text);
  font-weight: 500; }
.admin-section { background: var(--bg2); border: 0.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; }
.admin-section-title { font-size: 15px; font-weight: 700; margin-bottom: 16px;
  color: var(--text); }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th { padding: 8px 12px; text-align: left; font-size: 11px;
  font-weight: 600; color: var(--text3); background: var(--bg3);
  border-bottom: 0.5px solid var(--border); text-transform: uppercase; }
.admin-table td { padding: 9px 12px; border-bottom: 0.5px solid var(--border);
  font-size: 12px; }
.admin-table tr:last-child td { border-bottom: none; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  margin-right: 5px; }
.dot-active { background: var(--green); }
.dot-paused { background: var(--amber); }
.dot-inactive { background: var(--text3); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-bottom: 12px; }
.form-row.single { grid-template-columns: 1fr; }
.form-field label { display: block; font-size: 11px; font-weight: 500;
  color: var(--text2); margin-bottom: 4px; }
.form-field input, .form-field select { width: 100%; padding: 7px 10px;
  border: 0.5px solid var(--border2); border-radius: 6px; font-size: 13px;
  background: var(--bg); color: var(--text); outline: none; }
.form-field input:focus, .form-field select:focus { border-color: var(--blue); }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.match-queue-item { border: 0.5px solid var(--border); border-radius: var(--radius);
  padding: 12px; margin-bottom: 8px; }
.match-score { font-size: 11px; padding: 2px 7px; border-radius: 4px; }
.score-high { background: var(--green-bg); color: var(--green-text); }
.score-med { background: var(--amber-bg); color: var(--amber-text); }
.score-low { background: var(--red-bg); color: var(--red-text); }
.job-status { font-size: 11px; padding: 2px 7px; border-radius: 4px; }
.js-completed { background: var(--green-bg); color: var(--green-text); }
.js-pending { background: var(--amber-bg); color: var(--amber-text); }
.js-running { background: var(--blue-bg); color: var(--blue-text); }
.js-failed { background: var(--red-bg); color: var(--red-text); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .summary-strip { grid-template-columns: repeat(2, 1fr); }
  .analytics-grid { grid-template-columns: 1fr; }
  .dash-layout { flex-direction: column; }
  .filter-sidebar { width: 100%; }
  .detail-panel { width: 100%; }
  .admin-layout { grid-template-columns: 1fr; }
}

/* ── Utility ── */
.mt8 { margin-top: 8px; }
.mt16 { margin-top: 16px; }
.flex { display: flex; }
.gap8 { gap: 8px; }
.gap12 { gap: 12px; }
.flex-1 { flex: 1; }
.text-right { text-align: right; }
.spinner { display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--border); border-top-color: var(--blue);
  border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 40px; color: var(--text3); }
.empty-state h3 { font-size: 14px; margin-bottom: 6px; color: var(--text2); }
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--text);
  color: white; padding: 10px 18px; border-radius: var(--radius);
  font-size: 13px; z-index: 1000; box-shadow: var(--shadow-lg);
  animation: fadeIn 0.2s ease; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); } }
