:root {
  --bg: #f4f7fb;
  --ink: #0f172a;
  --muted: #64748b;
  --card: #ffffff;
  --line: #dbe3ef;
  --brand: #0b6e4f;
  --brand-dark: #084f39;
  --accent: #f59e0b;
  --error: #b91c1c;
  --ok: #15803d;
  --off: #dc2626;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% -10%, #d3f3e8 0, #f4f7fb 35%) no-repeat, var(--bg);
  min-height: 100vh;
}

.bg-shape {
  position: fixed;
  z-index: -1;
  pointer-events: none;
}

.bg-shape-a {
  width: 360px;
  height: 360px;
  border-radius: 50%;
  right: -120px;
  top: -80px;
  background: radial-gradient(circle, rgba(11, 110, 79, 0.2), rgba(11, 110, 79, 0));
}

.bg-shape-b {
  width: 300px;
  height: 300px;
  border-radius: 50%;
  left: -100px;
  bottom: -90px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.18), rgba(245, 158, 11, 0));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
}

.brand {
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  gap: 1rem;
}

.nav a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
}

.nav a:hover {
  color: var(--ink);
}

.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.25rem;
  animation: fade-up 260ms ease-out;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dashboard-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

h1 {
  margin: 0 0 0.35rem;
  font-size: 1.7rem;
}

h2 {
  margin: 0 0 0.8rem;
  font-size: 1.15rem;
}

p {
  margin: 0;
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.metric span {
  color: var(--muted);
  font-size: 0.86rem;
}

.metric strong {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.4rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.95rem;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04);
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 3.6fr) minmax(260px, 0.96fr);
  gap: 0.95rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) minmax(220px, 1.35fr) minmax(260px, 1.5fr) auto auto;
  gap: 0.6rem;
  align-items: start;
}

.source-form,
.auth-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 0.6rem;
}

.filter-row input,
.filter-row select,
.source-form input,
.source-form select,
.auth-form input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.56rem 0.65rem;
  font: inherit;
  background: #fff;
}

.btn {
  border: 0;
  border-radius: 9px;
  padding: 0.58rem 0.85rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-secondary {
  background: #1f2937;
  color: #fff;
}

.btn-danger {
  background: #991b1b;
  color: #fff;
}

.btn-ghost {
  border: 1px solid var(--line);
  background: #fff;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
}

.feat-legend {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.sort-hint {
  display: flex;
  align-items: center;
  line-height: 1.35;
  font-size: 0.82rem;
  color: var(--muted);
}

.source-filter-wrap {
  min-width: 0;
}

.source-dropdown {
  position: relative;
}

.source-dropdown summary {
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.56rem 0.65rem;
  font: inherit;
  background: #fff;
  cursor: pointer;
  color: #0f172a;
}

.source-dropdown summary::-webkit-details-marker {
  display: none;
}

.source-dropdown[open] summary {
  border-color: #93c5fd;
}

.source-dropdown-menu {
  position: absolute;
  z-index: 75;
  top: calc(100% + 0.35rem);
  left: 0;
  width: min(380px, 90vw);
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
  padding: 0.45rem 0.5rem;
}

.source-option {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-start;
  padding: 0.22rem 0.12rem;
  font-size: 0.88rem;
  cursor: pointer;
  width: 100%;
}

.source-option input {
  order: 2;
  margin-top: 0;
  margin-left: auto;
  width: auto;
  flex: 0 0 auto;
}

.source-option span {
  flex: 1;
  text-align: left;
}

.source-empty {
  color: var(--muted);
  font-size: 0.86rem;
  padding: 0.3rem 0.15rem;
}

.scan-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}

.last-scan {
  color: var(--muted);
}

.last-scan a {
  color: #0b6e4f;
  font-weight: 700;
  text-decoration: none;
}

.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  text-decoration: none;
  color: inherit;
  font-weight: 700;
}

.sort-link:hover {
  color: #0b6e4f;
}

.sort-arrow {
  color: #2563eb;
  font-size: 0.78rem;
}

.feature-col {
  text-align: center;
  min-width: 52px;
}

.feat-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  padding: 0.18rem 0.35rem;
  border: 1px solid #cfe0f7;
  border-radius: 999px;
  background: #eef5ff;
  color: #1f3a8a;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.55rem;
  vertical-align: top;
  font-size: 0.9rem;
}

th {
  color: #1e293b;
  text-align: left;
  font-size: 0.8rem;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  background: #f8fbff;
  box-shadow: inset 0 -1px 0 #dbe3ef;
}

.norm-cell {
  font-weight: 600;
}

.norm-pill {
  display: inline-block;
  padding: 0.16rem 0.34rem;
  border-radius: 8px;
}

.norm-pill .metric-number {
  display: block;
  white-space: nowrap;
}

.norm-pill .metric-unit {
  display: block;
  line-height: 1.15;
}

.norm-cell.norm-has .norm-pill {
  background: hsl(calc(var(--norm, 0) * 120), 78%, 91%);
}

.norm-cell.norm-missing .norm-pill {
  color: var(--muted);
  background: #f8fafc;
}

.table-floating-header {
  position: fixed;
  display: none;
  z-index: 60;
  pointer-events: auto;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
  background: #f8fbff;
}

.table-floating-header table {
  border-collapse: collapse;
  min-width: 900px;
}

.table-floating-header th {
  background: #f8fbff;
}

.thumb {
  width: 110px;
  height: 62px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.car-link {
  display: inline-flex;
  gap: 0.65rem;
  align-items: flex-start;
  text-decoration: none;
  color: inherit;
}

.car-link small {
  display: block;
  color: var(--muted);
  margin-top: 0.2rem;
}

.row-new td {
  border-bottom-color: #d9f2be;
}

.row-new-badge {
  display: inline-block;
  margin-left: 0.42rem;
  border-radius: 999px;
  padding: 0.08rem 0.46rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #3f6212;
  background: #ecfccb;
  border: 1px solid #bef264;
  vertical-align: middle;
}

.row-flash td {
  animation: row-flash-bg 1.6s ease-out;
}

@keyframes row-flash-bg {
  0% {
    background: #fde68a;
  }
  100% {
    background: transparent;
  }
}

.change-list,
.run-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.change-list li,
.run-list li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem;
  background: #fbfdff;
}

.change-list a,
.run-list a {
  text-decoration: none;
  color: #0f172a;
  font-weight: 600;
}

.change-jump-panel {
  display: block;
  width: 100%;
}

.change-list small,
.run-list small {
  display: block;
  color: var(--muted);
  margin-top: 0.2rem;
}

.change-type {
  display: inline-block;
  margin-right: 0.45rem;
  border-radius: 999px;
  padding: 0.14rem 0.46rem;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
}

.change-new {
  background: #dcfce7;
  color: #166534;
}

.change-price_changed {
  background: #fef3c7;
  color: #92400e;
}

.change-removed {
  background: #fee2e2;
  color: #991b1b;
}

.status {
  display: inline-block;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-success {
  background: #dcfce7;
  color: #166534;
}

.status-partial {
  background: #fef3c7;
  color: #92400e;
}

.status-failed {
  background: #fee2e2;
  color: #991b1b;
}

.status-running {
  background: #dbeafe;
  color: #1d4ed8;
}

.flag {
  display: inline-flex;
  width: 1.7rem;
  height: 1.5rem;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: 700;
}

.flag-on {
  background: #dcfce7;
  color: var(--ok);
}

.flag-off {
  background: #fee2e2;
  color: var(--off);
}

.inline-form {
  display: inline-flex;
  gap: 0.35rem;
  margin-right: 0.4rem;
  margin-bottom: 0.25rem;
}

.inline-form input,
.inline-form select {
  min-width: 120px;
}

.auth-wrap {
  min-height: 72vh;
  display: grid;
  place-items: center;
}

.auth-card {
  max-width: 460px;
  width: 100%;
}

.auth-form {
  margin-top: 1rem;
  grid-template-columns: 1fr;
}

.notify-form {
  margin-top: 0.85rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
  max-width: 540px;
}

.notify-form label {
  font-size: 0.88rem;
  color: #1e293b;
  font-weight: 600;
}

.check-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.5rem 0.65rem;
  background: #fbfdff;
}

.check-line input[type="checkbox"] {
  width: auto;
}

.notify-actions {
  margin-top: 0.35rem;
}

.muted {
  color: var(--muted);
}

.banner {
  margin-bottom: 0.9rem;
  padding: 0.6rem 0.75rem;
  border-radius: 9px;
  border: 1px solid #fde68a;
  background: #fffbeb;
}

.error {
  margin-top: 0.65rem;
  color: var(--error);
}

.error-log {
  white-space: pre-wrap;
  margin: 0;
  color: #7f1d1d;
}

@media (max-width: 1100px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .filter-row,
  .source-form {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-wrap: wrap;
  }
}
