:root {
  --nav: #182335;
  --nav-active: #4f46e5;
  --nav-active-soft: rgba(79, 70, 229, .14);
  --bg: #f3f6fb;
  --panel: #ffffff;
  --line: #dbe3ef;
  --line-strong: #c8d3e2;
  --text: #101827;
  --muted: #66758a;
  --green: #10b981;
  --orange: #f59e0b;
  --red: #ef4444;
  --blue-soft: #e8edff;
  --shadow-sm: 0 1px 2px rgba(16, 24, 39, .05);
  --shadow-md: 0 8px 24px rgba(16, 24, 39, .08);
  --shadow-lg: 0 24px 60px rgba(16, 24, 39, .18);
  --product-row-columns: 34px 44px minmax(220px, 2fr) minmax(92px, 0.8fr) minmax(112px, 1fr) minmax(78px, 0.7fr) minmax(96px, 0.85fr) minmax(96px, 0.85fr) 44px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.5;
}

[hidden] { display: none !important; }

.app-shell {
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

button, input, select {
  font: inherit;
}

button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  cursor: pointer;
  font-weight: 700;
  transition: border-color .16s ease, background .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}

button:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

button:active {
  transform: translateY(1px);
}

input, select {
  height: 38px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input:focus,
select:focus {
  border-color: var(--nav-active);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
  outline: none;
}

.side-nav {
  height: 100vh;
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,0) 36%),
    var(--nav);
  color: #dbe5f1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-right: 1px solid #172234;
}

.brand {
  height: 86px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255,255,255,.38);
  border-radius: 6px;
  background:
    linear-gradient(145deg, rgba(255,255,255,.18), rgba(255,255,255,.04)),
    rgba(255,255,255,.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14);
}

.brand-logo {
  width: 20px;
  height: 20px;
}

.brand-mark svg {
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-list {
  padding: 18px 12px;
  display: grid;
  align-content: start;
  gap: 6px;
}

.nav-item {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #c7d4e6;
  text-align: left;
  padding: 0 14px;
  font-weight: 700;
}

.nav-item:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
  box-shadow: none;
}

.nav-item.is-active {
  background: var(--nav-active);
  color: #fff;
  box-shadow: 0 8px 22px rgba(79, 70, 229, .28);
}

.side-footer {
  min-height: 86px;
  padding: 14px 16px 16px;
  display: grid;
  gap: 8px;
  align-content: center;
  border-top: 1px solid rgba(255,255,255,.08);
  color: #fff;
  font-weight: 700;
}

.side-stat,
.account-mini {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.side-stat {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.075);
  border: 1px solid rgba(255,255,255,.08);
}

.account-mini {
  color: #dbe5f1;
  font-size: 13px;
  min-width: 0;
}

#auth-username {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn,
#logout-btn {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 9px;
  border-color: rgba(255,255,255,.2);
  background: rgba(255,255,255,.08);
  color: #fff;
}

#logout-btn:hover {
  border-color: rgba(255,255,255,.34);
  background: rgba(255,255,255,.13);
}

.app-main {
  min-width: 0;
  padding: 24px 28px;
  overflow: auto;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at 14% 18%, rgba(79, 70, 229, .12), transparent 28%),
    linear-gradient(135deg, #eef2ff 0%, #f8fafc 48%, #edf7f4 100%);
}

.auth-card {
  width: min(1040px, 100%);
  min-height: 590px;
  display: grid;
  grid-template-columns: 1.18fr 0.82fr;
  border: 1px solid rgba(255,255,255,.74);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-size: 18px;
}

.auth-brand-panel {
  position: relative;
  display: grid;
  align-content: space-between;
  min-height: 590px;
  padding: 48px;
  overflow: hidden;
  background:
    linear-gradient(140deg, rgba(79, 70, 229, .92), rgba(24, 35, 53, .98)),
    var(--nav);
  color: #fff;
}

.auth-brand-panel::after {
  content: '';
  position: absolute;
  right: -96px;
  bottom: -118px;
  width: 330px;
  height: 330px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  background: rgba(255,255,255,.055);
}

.auth-brand-copy {
  position: relative;
  z-index: 1;
  max-width: 520px;
}

.auth-brand-copy span,
.auth-form-head span {
  display: block;
  margin-bottom: 12px;
  color: rgba(255,255,255,.74);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .08em;
}

.auth-brand-copy h1 {
  max-width: 520px;
  font-size: 42px;
  line-height: 1.16;
  color: #fff;
}

.auth-brand-copy p {
  max-width: 460px;
  margin: 18px 0 0;
  color: rgba(255,255,255,.78);
  font-size: 16px;
  line-height: 1.8;
}

.auth-brand-metrics {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-brand-metrics span {
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.86);
  font-size: 13px;
  font-weight: 800;
}

.auth-form-panel {
  display: grid;
  align-content: center;
  gap: 26px;
  padding: 56px 52px;
  background: #fff;
}

.auth-form-head span {
  color: var(--nav-active);
}

.auth-form-head h1 {
  font-size: 30px;
}

.auth-card form {
  display: grid;
  gap: 16px;
}

.auth-card .field {
  gap: 8px;
}

.auth-card input {
  height: 44px;
}

.auth-card .primary-btn {
  width: 100%;
  height: 44px;
  margin-top: 2px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.topbar p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.primary-btn {
  border-color: var(--nav-active);
  background: var(--nav-active);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(79, 70, 229, .2);
}

.primary-btn:hover {
  border-color: #4338ca;
  background: #4338ca;
  box-shadow: 0 10px 24px rgba(79, 70, 229, .28);
}

.filter-bar {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.88);
  box-shadow: var(--shadow-sm);
}

.filter-row {
  display: grid;
  gap: 8px;
  align-items: center;
}

.filter-row-selects {
  grid-template-columns: minmax(280px, 1fr) 118px 118px 118px 78px;
}

.filter-row-numbers {
  grid-template-columns: auto minmax(116px, 1fr) minmax(116px, 1fr) auto repeat(4, minmax(116px, 1fr));
}

.filter-group-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.bulk-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  margin-bottom: 10px;
  padding: 8px 12px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff5f5;
  color: #991b1b;
  font-size: 13px;
  font-weight: 800;
}

.list-header,
.product-row {
  display: grid;
  grid-template-columns: var(--product-row-columns);
  gap: 14px;
  align-items: center;
}

.list-header > *,
.product-row > * {
  min-width: 0;
}

.list-header {
  padding: 2px 16px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

.sortable-header {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  width: 100%;
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.sortable-header:hover,
.sortable-header.is-active {
  color: var(--text);
}

.sort-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  min-width: 12px;
  color: var(--nav-active);
  font-size: 12px;
  line-height: 1;
}

.product-list {
  display: grid;
  gap: 12px;
}

.product-row {
  min-height: 116px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.product-row:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.favorite-btn {
  width: 36px;
  padding: 0;
  color: #94a3b8;
  font-size: 22px;
  border-radius: 8px;
}

.select-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.select-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--nav-active);
  cursor: pointer;
}

.favorite-btn.is-on {
  color: var(--orange);
  border-color: #fed7aa;
  background: #fff7ed;
}

.product-main {
  min-width: 0;
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.thumb {
  width: 78px;
  height: 78px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(180deg, #fff, #f8fafc);
}

.thumb.is-pending {
  background:
    linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.72), rgba(255,255,255,0)),
    linear-gradient(180deg, #eef2f7, #f8fafc);
  background-size: 160% 100%, 100% 100%;
  animation: image-pending-sheen 1.2s ease-in-out infinite;
  opacity: .72;
}

.thumb.is-loaded {
  opacity: 1;
  transition: opacity .18s ease;
}

.thumb.is-error {
  background:
    linear-gradient(180deg, #fff, #f8fafc),
    repeating-linear-gradient(45deg, #eef2f7 0 8px, #f8fafc 8px 16px);
}

@keyframes image-pending-sheen {
  0% { background-position: 120% 0, 0 0; }
  100% { background-position: -120% 0, 0 0; }
}

.title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 800;
  line-height: 1.35;
  color: #0f172a;
}

.meta {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.analysis-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.competitor-summary-line {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.verdict-good {
  background: #ecfdf5;
  color: #047857;
}

.verdict-watch {
  background: #fff7ed;
  color: #c2410c;
}

.verdict-bad {
  background: #fef2f2;
  color: #b91c1c;
}

.asin-link {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #3b5ccc;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  vertical-align: middle;
}

.asin-link:hover {
  color: #263fb0;
  text-decoration: underline;
}

.metric {
  line-height: 1.45;
  font-size: 13px;
}

.metric strong {
  display: block;
  font-size: 17px;
  color: #0f172a;
}

.muted { color: var(--muted); }
.profit { color: var(--green) !important; font-size: 20px !important; font-weight: 900; }
.danger { color: var(--red); }
.level-a, .level-s { color: var(--orange); font-weight: 900; }
.level-b, .level-c { color: var(--green); font-weight: 900; }

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.icon-btn {
  width: 36px;
  padding: 0;
  border-radius: 8px;
}

.danger-btn {
  display: inline-grid;
  place-items: center;
  color: var(--muted);
}

.danger-btn:hover {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--red);
}

.trash-icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.competitor-panel {
  margin-top: -10px;
  padding: 18px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.78);
}

.analysis-detail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.analysis-detail-block {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.analysis-detail-block.is-expanded {
  grid-column: 1 / -1;
}

.analysis-detail-block header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.analysis-detail-block header span {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

.analysis-detail-block p,
.analysis-detail-block li {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.analysis-detail-body {
  position: relative;
  max-height: 96px;
  overflow: hidden;
}

.analysis-detail-block.is-expanded .analysis-detail-body {
  max-height: none;
  overflow: visible;
}

.analysis-detail-block.is-collapsed .analysis-detail-body::after {
  content: '...';
  position: absolute;
  right: 0;
  bottom: 0;
  padding: 0 0 0 28px;
  background: linear-gradient(90deg, rgba(255,255,255,0), #fff 42%);
  color: var(--muted);
  font-weight: 800;
}

.analysis-detail-block p {
  margin: 0 0 8px;
}

.analysis-detail-block ul {
  margin: 0;
  padding-left: 18px;
}

.analysis-toggle {
  height: 28px;
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #3b5ccc;
  font-size: 13px;
  font-weight: 800;
}

.analysis-toggle:hover {
  text-decoration: underline;
}

.final-review-report {
  grid-column: 1 / -1;
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.final-report-body {
  display: grid;
  gap: 12px;
}

.final-review-report.is-collapsed .final-report-body {
  display: none;
}

.final-review-report.is-expanded .final-report-body {
  display: grid;
}

.final-report-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 136px;
  gap: 12px;
  align-items: stretch;
  padding-bottom: 12px;
  border-bottom: 1px solid #eef2f7;
}

.final-report-head strong {
  display: block;
  color: var(--text);
  font-size: 15px;
}

.final-report-head p,
.final-report-section p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.final-verdict-box {
  display: grid;
  align-content: center;
  justify-items: end;
  padding: 10px;
  border: 1px solid #eef2f7;
  border-radius: 8px;
  background: #f8fafc;
}

.final-verdict-box span,
.competition-plan-grid span,
.score-breakdown-grid span {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 800;
}

.final-verdict-box strong {
  color: var(--text);
  font-size: 20px;
  font-weight: 900;
}

.final-report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.final-report-section {
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid #eef2f7;
  border-radius: 8px;
  background: #fbfdff;
}

.final-report-section h3 {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.final-plan-section {
  background: #f9fbff;
}

.competition-plan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 9px;
}

.competition-plan-grid div,
.score-breakdown-grid div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #eef2f7;
  border-radius: 8px;
  background: #fff;
}

.competition-plan-grid strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.score-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 9px;
}

.score-breakdown-grid strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
}

.score-breakdown-grid small {
  margin-left: 2px;
  color: var(--muted);
  font-size: 11px;
}

.competitor-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.competitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(286px, 1fr));
  gap: 14px;
}

.competitor-card {
  position: relative;
  min-width: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 11px;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.competitor-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.competitor-head {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.competitor-card .thumb {
  width: 88px;
  height: 88px;
}

.competitor-image-link {
  display: inline-block;
  width: 88px;
  height: 88px;
}

.compact-title {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
  min-height: 3.9em;
}

.competitor-title-link {
  display: block;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.competitor-image-link:hover .thumb,
.competitor-title-link:hover {
  border-color: var(--line-strong);
  color: #3b5ccc;
  text-decoration: underline;
}

.score-strip {
  padding: 9px 10px;
  display: grid;
  grid-template-columns: auto minmax(74px, 1fr) minmax(86px, 1fr);
  align-items: center;
  gap: 8px;
  background: #f4f7fb;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  cursor: help;
  outline: none;
}

.score-strip:hover,
.score-strip:focus-within {
  background: #e8edff;
}

.score-strip strong {
  margin-left: 3px;
  color: var(--green);
  font-size: 14px;
}

.score-strip span:first-child {
  color: var(--text);
}

.competitor-calc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.cost-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.competitor-calc-cell,
.cost-edit-cell {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #eef2f7;
  border-radius: 8px;
  background: #f8fafc;
}

.competitor-calc-cell strong,
.cost-grid strong {
  display: block;
  color: var(--text);
  font-size: 15px;
}

.cost-edit-cell label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 50px;
  gap: 4px;
  margin-top: 5px;
}

.competitor-cost-input {
  width: 100%;
  min-width: 0;
  height: 30px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}

.cost-edit-cell button {
  height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.competitor-result-row {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: 8px;
  padding-top: 10px;
  border-top: 1px dashed #dbe3ef;
}

.competitor-result-box {
  min-width: 0;
}

.competitor-result-box span {
  display: block;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 800;
}

.competitor-result-box strong {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--text);
  font-size: 16px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.competitor-result-box [data-competitor-margin] {
  color: var(--green);
  font-size: 20px;
}

.competitor-save-status,
.competitor-package-line {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.competitor-analysis-popover {
  position: fixed;
  z-index: 1000;
  left: var(--popover-left, 12px);
  top: var(--popover-top, 12px);
  display: none;
  width: min(360px, calc(100vw - 24px));
  max-height: 320px;
  overflow: auto;
  padding: 12px;
  background: #111827;
  color: #f8fafc;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.28);
  pointer-events: none;
}

.score-strip:hover + .competitor-analysis-popover,
.score-strip:focus-within + .competitor-analysis-popover,
.competitor-analysis-popover.is-visible {
  display: block;
}

.competitor-analysis-popover p {
  margin: 8px 0 0;
  color: #d1d5db;
  font-size: 12px;
  line-height: 1.55;
}

.competitor-analysis-popover p strong {
  display: inline;
  color: #f8fafc;
  font-size: 12px;
}

.popover-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 5px 10px;
  font-size: 12px;
}

.popover-grid span {
  color: #9ca3af;
}

.popover-grid strong {
  color: #f8fafc;
  font-size: 12px;
}

.empty-state,
.loading-state {
  padding: 42px;
  text-align: center;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
}

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 18px 0 4px;
  flex-wrap: wrap;
}

.page-size-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.page-size-control select {
  min-width: 86px;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, .45);
}

.modal-root[hidden] {
  display: none;
}

.modal {
  width: min(560px, calc(100vw - 32px));
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}

.modal-header,
.modal-footer {
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.modal-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-body {
  padding: 20px;
  display: grid;
  gap: 12px;
}

.file-box {
  min-height: 120px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  text-align: center;
}

.manual-asin-input {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font: inherit;
  line-height: 1.5;
}

.status-note {
  color: var(--muted);
  font-size: 13px;
}

.settings-form,
.task-board {
  display: grid;
  gap: 12px;
}

.settings-section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.settings-section h2 {
  margin: 0 0 12px;
  font-size: 16px;
  letter-spacing: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
}

.field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
  accent-color: var(--nav-active);
  cursor: pointer;
}

.field:has(input[type="checkbox"]) {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-height: 38px;
}

.backup-model-field {
  align-self: start;
}

.backup-model-editor {
  display: grid;
  gap: 8px;
}

.backup-model-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.backup-model-item {
  width: fit-content;
  max-width: 100%;
  display: inline-grid;
  grid-template-columns: 14px minmax(0, auto) 20px;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 3px 4px 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--text);
  cursor: grab;
  font-size: 12px;
}

.backup-model-item.is-dragging {
  opacity: .55;
}

.backup-model-drag {
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0;
  text-align: center;
}

.backup-model-name {
  overflow-wrap: anywhere;
  font-weight: 700;
}

.backup-model-remove,
.backup-model-add-row button {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.backup-model-remove:hover,
.backup-model-add-row button:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.backup-model-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  align-items: center;
  gap: 8px;
}

.diagnostic-actions {
  display: grid;
  grid-template-columns: minmax(180px, 260px) max-content max-content;
  align-items: end;
  gap: 10px;
}

.diagnostic-asin {
  min-width: 0;
}

.diagnostic-status {
  margin-top: 12px;
}

.diagnostic-status pre {
  max-height: 180px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--text);
  white-space: pre-wrap;
}

.account-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) max-content minmax(120px, 1fr);
  align-items: end;
  gap: 12px;
}

.account-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  box-shadow: var(--shadow-sm);
}

.account-row div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.account-row span {
  color: var(--muted);
  font-size: 13px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.task-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.task-toolbar .status-note {
  margin-left: 4px;
}

.task-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.task-card strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.task-summary,
.task-event-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.task-summary {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.task-summary > div {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.task-summary span {
  color: var(--muted);
  font-size: 13px;
}

.task-summary strong {
  color: var(--text);
}

.task-event-panel header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.task-event-panel header span {
  color: var(--muted);
  font-size: 13px;
}

.task-event-list {
  display: grid;
}

.task-event-row {
  display: grid;
  grid-template-columns: 112px 82px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.task-event-row:last-child {
  border-bottom: 0;
}

.task-event-row time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.task-event-type {
  width: fit-content;
  padding: 3px 7px;
  border-radius: 6px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 700;
}

.event-success .task-event-type {
  background: #ecfdf5;
  color: #047857;
}

.event-retry_wait .task-event-type,
.event-skipped .task-event-type {
  background: #fff7ed;
  color: #c2410c;
}

.event-paused .task-event-type,
.event-failed .task-event-type {
  background: #fef2f2;
  color: #b91c1c;
}

.task-event-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.task-event-main div {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.task-event-main strong {
  font-size: 13px;
}

.task-event-main span,
.task-event-main p {
  color: var(--muted);
  font-size: 13px;
}

.task-event-main p {
  margin: 0;
  overflow-wrap: anywhere;
}

.task-event-error {
  color: #b91c1c !important;
}

@media (max-width: 1180px) {
  :root {
    --product-row-columns: 32px 40px minmax(190px, 2fr) minmax(82px, 0.75fr) minmax(96px, 0.9fr) minmax(64px, 0.6fr) minmax(78px, 0.7fr) minmax(78px, 0.7fr) 44px;
  }
  .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .brand span:last-child,
  .nav-item,
  .side-stat span:first-child { font-size: 0; }
  .account-mini { display: none; }
  .nav-item::first-letter { font-size: 16px; }
  .filter-row-selects {
    grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(96px, 1fr)) 72px;
  }
  .filter-row-numbers {
    grid-template-columns: auto repeat(2, minmax(98px, 1fr)) auto repeat(4, minmax(98px, 1fr));
  }
  .list-header { display: none; }
}

@media (max-width: 760px) {
  .auth-view {
    padding: 18px;
  }
  .auth-card {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .auth-brand-panel {
    min-height: 300px;
    padding: 28px;
  }
  .auth-brand-copy h1 {
    font-size: 28px;
  }
  .auth-brand-copy p {
    font-size: 14px;
    line-height: 1.65;
  }
  .auth-form-panel {
    padding: 28px;
  }
  .app-shell {
    display: block;
    height: auto;
    overflow: visible;
  }
  .side-nav {
    height: auto;
    min-height: auto;
    grid-template-rows: auto;
  }
  .brand, .side-footer { display: none; }
  .nav-list {
    grid-auto-flow: column;
    overflow-x: auto;
    padding: 8px;
  }
  .nav-item {
    width: auto;
    min-width: 88px;
    height: 38px;
    border-radius: 6px;
    font-size: 14px;
    padding: 0 10px;
  }
  .topbar,
  .filter-bar {
    display: grid;
    grid-template-columns: 1fr;
  }
  .app-main {
    padding: 16px;
  }
  .top-actions {
    flex-wrap: wrap;
  }
  .filter-row-selects,
  .filter-row-numbers {
    grid-template-columns: 1fr;
  }
  .filter-group-label {
    margin-top: 2px;
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .diagnostic-actions {
    grid-template-columns: 1fr;
  }
  .account-form {
    grid-template-columns: 1fr;
  }
  .analysis-detail {
    grid-template-columns: 1fr;
  }
  .final-report-head,
  .final-report-grid,
  .competition-plan-grid,
  .score-breakdown-grid {
    grid-template-columns: 1fr;
  }
  .final-verdict-box {
    justify-items: start;
  }
  .product-row {
    grid-template-columns: 28px 36px minmax(0, 1fr);
  }
  .product-row > :nth-child(n+4) {
    grid-column: 3;
  }
  .row-actions {
    justify-content: flex-start;
  }
}
