:root {
  --pricetool-primary: #1B4F8A;
  --pricetool-primary-dark: #153F6E;
  --pricetool-primary-soft: #EAF2FA;
  --pricetool-border: #E3E8EF;
  --pricetool-muted: #637381;
  --pricetool-bg: #F6F8FB;
  --pricetool-surface: #ffffff;
  --pricetool-surface-alt: #F8FAFC;
  --pricetool-text: #1F2937;
  --pricetool-heading: #0F172A;
  --pricetool-subtle: #94A3B8;
  --pricetool-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
  --pricetool-navbar: #1B4F8A;
  --pricetool-sidebar: #ffffff;
  --pricetool-table-head: #F8FAFC;
  --pricetool-hover: #F3F8FD;
  --pricetool-success-bg: #f0fdf4;
  --pricetool-own-bg: #eff6ff;
  --pricetool-input-bg: #ffffff;
  --pricetool-input-color: #111827;
  --pricetool-focus-shadow: 0 0 0 0.2rem rgba(27, 79, 138, 0.18);
}

:root[data-theme="dark"] {
  --pricetool-primary: #93C5FD;
  --pricetool-primary-dark: #60A5FA;
  --pricetool-primary-soft: rgba(96, 165, 250, 0.13);
  --pricetool-accent: #FDBA74;
  --pricetool-accent-soft: rgba(251, 146, 60, 0.14);
  --pricetool-border: rgba(228, 228, 231, 0.10);
  --pricetool-muted: #A1A1AA;
  --pricetool-bg: #0B0D12;
  --pricetool-surface: #12161F;
  --pricetool-surface-alt: #181D27;
  --pricetool-text: #E4E4E7;
  --pricetool-heading: #FAFAFA;
  --pricetool-subtle: #71717A;
  --pricetool-shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
  --pricetool-navbar: rgba(10, 13, 19, 0.92);
  --pricetool-sidebar: #0F131B;
  --pricetool-table-head: #171C26;
  --pricetool-hover: rgba(96, 165, 250, 0.09);
  --pricetool-success-bg: rgba(16, 185, 129, 0.12);
  --pricetool-own-bg: rgba(59, 130, 246, 0.12);
  --pricetool-input-bg: #0F141D;
  --pricetool-input-color: #F4F4F5;
  --pricetool-focus-shadow: 0 0 0 0.18rem rgba(96, 165, 250, 0.18);
}

body {
  min-height: 100vh;
  color: var(--pricetool-text);
  background: var(--pricetool-bg);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background:
    radial-gradient(circle at 18% 0%, rgba(96, 165, 250, 0.13), transparent 30%),
    radial-gradient(circle at 82% 4%, rgba(251, 146, 60, 0.08), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 32%);
  opacity: 0;
}

:root[data-theme="dark"] body::before {
  opacity: 1;
}

a {
  color: var(--pricetool-primary);
}

.text-muted {
  color: var(--pricetool-muted) !important;
}

.form-control,
.form-select {
  color: var(--pricetool-input-color);
  border-color: var(--pricetool-border);
  background-color: var(--pricetool-input-bg);
}

.form-control:focus,
.form-select:focus {
  color: var(--pricetool-input-color);
  border-color: var(--pricetool-primary);
  background-color: var(--pricetool-input-bg);
  box-shadow: var(--pricetool-focus-shadow);
}

.form-control::placeholder {
  color: var(--pricetool-subtle);
}

.table {
  --bs-table-color: var(--pricetool-text);
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--pricetool-border);
  --bs-table-hover-color: var(--pricetool-text);
  --bs-table-hover-bg: var(--pricetool-hover);
}

.dropdown-menu,
.offcanvas {
  color: var(--pricetool-text);
  border-color: var(--pricetool-border);
  background: var(--pricetool-surface);
}

.btn-outline-secondary {
  --bs-btn-color: var(--pricetool-muted);
  --bs-btn-border-color: var(--pricetool-border);
  --bs-btn-hover-color: var(--pricetool-heading);
  --bs-btn-hover-bg: var(--pricetool-hover);
  --bs-btn-hover-border-color: var(--pricetool-primary);
}

.btn-primary {
  --bs-btn-bg: var(--pricetool-primary);
  --bs-btn-border-color: var(--pricetool-primary);
  --bs-btn-hover-bg: var(--pricetool-primary-dark);
  --bs-btn-hover-border-color: var(--pricetool-primary-dark);
}

:root[data-theme="dark"] .btn-primary {
  --bs-btn-color: #ffffff;
  --bs-btn-hover-color: #ffffff;
}

.btn-outline-primary {
  --bs-btn-color: var(--pricetool-primary);
  --bs-btn-border-color: var(--pricetool-primary);
  --bs-btn-hover-bg: var(--pricetool-primary);
  --bs-btn-hover-border-color: var(--pricetool-primary);
}

.app-navbar {
  border-bottom: 1px solid var(--pricetool-border);
  background: var(--pricetool-navbar);
  backdrop-filter: blur(16px);
}

:root[data-theme="dark"] .app-navbar {
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04), 0 18px 60px rgba(0, 0, 0, 0.32);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 10px;
  color: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 13px;
  font-weight: 600;
}

.theme-toggle:hover {
  color: #ffffff;
  border-color: rgba(147, 197, 253, 0.38);
  background: rgba(96, 165, 250, 0.14);
}

.app-shell {
  display: flex;
  min-height: calc(100vh - 56px);
}

.sidebar {
  width: 260px;
  flex: 0 0 260px;
  align-self: flex-start;
  height: calc(100vh - 56px);
  padding: 24px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--pricetool-border);
  background: var(--pricetool-sidebar);
  position: sticky;
  top: 56px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--pricetool-text);
  border-radius: 8px;
  text-decoration: none;
}

.sidebar-link i {
  width: 20px;
  color: var(--pricetool-primary);
  text-align: center;
}

.sidebar-link:hover,
.sidebar-link.active {
  color: var(--pricetool-primary);
  background: var(--pricetool-primary-soft);
}

.sidebar-link.disabled {
  color: var(--pricetool-subtle);
  pointer-events: none;
}

.sidebar-link.disabled i {
  color: var(--pricetool-subtle);
}

.sidebar::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-thumb {
  border: 2px solid var(--pricetool-sidebar);
  border-radius: 999px;
  background: var(--pricetool-subtle);
}

.content {
  width: 100%;
  min-width: 0;
  padding: 28px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  color: var(--pricetool-heading);
}

.page-header p {
  margin: 6px 0 0;
  color: var(--pricetool-muted);
}

.panel,
.metric-card,
.login-card {
  border: 1px solid var(--pricetool-border);
  border-radius: 8px;
  background: var(--pricetool-surface);
  box-shadow: var(--pricetool-shadow);
}

:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .metric-card,
:root[data-theme="dark"] .login-card,
:root[data-theme="dark"] .product-work-row {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
}

.panel {
  padding: 20px;
}

.panel-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--pricetool-border);
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 150px;
  padding: 20px;
}

.metric-card.compact {
  min-height: 110px;
}

.metric-card.success .metric-icon {
  color: #15803d;
  background: rgba(22, 163, 74, 0.14);
}

.metric-card.danger .metric-icon {
  color: #b91c1c;
  background: rgba(220, 38, 38, 0.14);
}

.metric-card span {
  color: var(--pricetool-muted);
}

.metric-card strong {
  font-size: 30px;
  line-height: 1;
}

.metric-card .metric-date {
  font-size: 18px;
  line-height: 1.25;
}

.metric-card .metric-label {
  font-size: 18px;
  line-height: 1.25;
}

.metric-icon {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: var(--pricetool-primary);
  border-radius: 8px;
  background: var(--pricetool-primary-soft);
}

.auth-page {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: linear-gradient(135deg, #F8FAFC 0%, #EAF2FA 100%);
}

:root[data-theme="dark"] .auth-page {
  background:
    radial-gradient(circle at 20% 0%, rgba(96, 165, 250, 0.14), transparent 34%),
    radial-gradient(circle at 85% 10%, rgba(251, 146, 60, 0.10), transparent 30%),
    var(--pricetool-bg);
}

.login-card {
  width: min(100%, 420px);
  padding: 28px;
}

.auth-page .flash-stack {
  position: absolute;
  top: max(24px, calc(50% - 300px));
  left: 50%;
  width: min(420px, calc(100% - 48px));
  margin: 0;
  transform: translateX(-50%);
  z-index: 2;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  color: #ffffff;
  border-radius: 8px;
  background: var(--pricetool-primary);
  font-weight: 700;
}

.flash-stack {
  margin-bottom: 20px;
}

.product-table th {
  color: var(--pricetool-muted);
  background: var(--pricetool-table-head);
  font-size: 13px;
  text-transform: uppercase;
}

.product-thumb {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  object-fit: contain;
  border: 1px solid var(--pricetool-border);
  border-radius: 6px;
  background: var(--pricetool-surface);
}

.product-thumb-empty {
  color: var(--pricetool-subtle);
  background: var(--pricetool-surface-alt);
}

.product-detail-media {
  display: grid;
  width: 100%;
  min-height: 220px;
  place-items: center;
  border: 1px solid var(--pricetool-border);
  border-radius: 8px;
  background: var(--pricetool-surface);
}

.product-detail-media img {
  max-width: 100%;
  max-height: 260px;
  object-fit: contain;
}

.product-detail-media span {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  color: var(--pricetool-subtle);
  border-radius: 8px;
  background: var(--pricetool-surface-alt);
  font-size: 28px;
}

.lowest-price-row {
  --bs-table-bg: var(--pricetool-success-bg);
}

.own-price-row {
  --bs-table-bg: var(--pricetool-own-bg);
}

.price-progress {
  height: 8px;
}

.table-link {
  color: var(--pricetool-primary);
  font-weight: 600;
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

.clickable-row {
  cursor: pointer;
}

.detail-list {
  display: grid;
  grid-template-columns: minmax(120px, 42%) 1fr;
  gap: 10px 16px;
}

.detail-list dt {
  color: var(--pricetool-muted);
  font-weight: 600;
}

.detail-list dd {
  margin: 0;
}

.sync-status:empty {
  display: none;
}

.price-rule-editor .panel {
  display: grid;
  gap: 24px;
}

.rule-section {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--pricetool-border);
}

.rule-section-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.rule-section-heading h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

:root[data-theme="dark"] .brand-mark {
  color: #ffffff;
}

.rule-section-heading p {
  margin: 4px 0 0;
  color: var(--pricetool-muted);
}

.rule-step {
  display: inline-grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  place-items: center;
  color: var(--pricetool-primary);
  border-radius: 8px;
  background: var(--pricetool-primary-soft);
  font-weight: 700;
}

.scope-preview-panel {
  position: sticky;
  top: 84px;
}

.scope-preview-list {
  display: grid;
  gap: 10px;
}

.scope-preview-item {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 10px;
  color: inherit;
  border: 1px solid var(--pricetool-border);
  border-radius: 8px;
  text-decoration: none;
}

:root[data-theme="dark"] .sidebar-link {
  color: #D4D4D8;
}

.scope-preview-item:hover {
  border-color: var(--pricetool-primary);
  background: var(--pricetool-hover);
}

.scope-preview-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.scope-preview-copy strong,
.scope-preview-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scope-preview-copy small {
  color: var(--pricetool-muted);
}

.scan-source-list {
  display: grid;
  gap: 8px;
  min-width: 320px;
}

.scan-source-list details {
  border: 1px solid var(--pricetool-border);
  border-radius: 6px;
  padding: 8px;
  background: var(--pricetool-surface);
}

.scan-source-list summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
}

.scan-attempt {
  padding: 8px 0;
  border-top: 1px solid var(--pricetool-border);
}

.scan-attempt:first-child {
  border-top: 0;
}

.price-group-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.price-group-card {
  display: grid;
  gap: 6px;
  min-height: 86px;
  padding: 14px;
  color: inherit;
  border: 1px solid var(--pricetool-border);
  border-radius: 8px;
  background: var(--pricetool-surface);
  text-decoration: none;
}

.price-group-card:hover,
.price-group-card.active {
  border-color: var(--pricetool-primary);
  background: var(--pricetool-hover);
}

.price-group-card span {
  color: var(--pricetool-muted);
}

.price-group-card strong {
  font-size: 24px;
}

.price-group-card.reset {
  border-style: dashed;
}

.product-list-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
}

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

.product-work-row {
  display: grid;
  grid-template-columns: 28px minmax(360px, 1.35fr) 180px minmax(420px, 2fr);
  gap: 12px;
  align-items: stretch;
  padding: 14px;
  border: 1px solid var(--pricetool-border);
  border-radius: 8px;
  background: var(--pricetool-surface);
  box-shadow: var(--pricetool-shadow);
}

.product-work-row.is-selected {
  border-color: var(--pricetool-primary);
  background: var(--pricetool-hover);
}

.product-select-cell {
  padding-top: 6px;
}

.product-summary-cell {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  min-width: 0;
}

.product-work-thumb {
  display: grid;
  width: 96px;
  height: 96px;
  place-items: center;
  object-fit: contain;
  border: 1px solid var(--pricetool-border);
  border-radius: 6px;
  background: var(--pricetool-surface);
}

.product-work-copy {
  min-width: 0;
}

.product-work-copy .table-link {
  display: block;
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-work-copy dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 10px;
  margin: 10px 0 0;
  font-size: 13px;
}

.product-work-copy dt {
  color: var(--pricetool-muted);
  font-weight: 600;
}

.product-work-copy dd {
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.own-price-card {
  display: grid;
  align-content: start;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--pricetool-border);
  border-radius: 8px;
  background: var(--pricetool-surface-alt);
}

:root[data-theme="dark"] .own-price-card,
:root[data-theme="dark"] .competitor-card,
:root[data-theme="dark"] .competitor-empty {
  border-color: rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025)),
    rgba(24, 29, 39, 0.62);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 18px 42px rgba(0, 0, 0, 0.20);
  backdrop-filter: blur(14px);
}

.own-price-card span,
.own-price-card small {
  color: var(--pricetool-muted);
}

.own-price-card strong {
  color: var(--pricetool-heading);
  font-size: 24px;
}

.own-price-card .badge {
  justify-self: start;
  margin-top: 4px;
  color: #ffffff;
}

.competitor-strip {
  display: grid;
  grid-auto-columns: minmax(150px, 170px);
  grid-auto-flow: column;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 4px;
}

.competitor-card {
  display: grid;
  gap: 8px;
  min-height: 118px;
  padding: 10px;
  color: inherit;
  border: 1px solid var(--pricetool-border);
  border-radius: 8px;
  background: var(--pricetool-surface-alt);
  text-decoration: none;
}

.competitor-card:hover {
  border-color: var(--pricetool-primary);
  background: var(--pricetool-hover);
}

:root[data-theme="dark"] .competitor-card:hover {
  border-color: rgba(147, 197, 253, 0.34);
  background:
    linear-gradient(180deg, rgba(147, 197, 253, 0.11), rgba(255, 255, 255, 0.028)),
    rgba(24, 29, 39, 0.72);
}

.competitor-shop {
  overflow: hidden;
  color: var(--pricetool-heading);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.competitor-card strong {
  font-size: 18px;
}

.competitor-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--pricetool-muted);
  font-size: 12px;
}

.competitor-empty {
  display: grid;
  min-height: 118px;
  place-items: center;
  color: var(--pricetool-muted);
  border: 1px dashed var(--pricetool-border);
  border-radius: 8px;
  background: var(--pricetool-surface-alt);
}

@media (max-width: 991.98px) {
  .content {
    padding: 20px;
  }

  .page-header {
    display: grid;
  }

  .scope-preview-panel {
    position: static;
  }

  .price-group-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-work-row {
    grid-template-columns: 28px 1fr;
  }

  .own-price-card,
  .competitor-strip {
    grid-column: 2;
  }
}
