@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #11161b;
  color: #e5e7eb;
  --bg: #11161b;
  --surface: #171d23;
  --surface-2: #1d242b;
  --surface-3: #212a32;
  --border: #313b46;
  --border-strong: #43515f;
  --text: #e5e7eb;
  --muted: #98a2ad;
  --muted-2: #6f7a85;
  --accent: #22c55e;
  --accent-strong: #16a34a;
  --accent-soft: #163c27;
  --warning-bg: #2f2415;
  --warning-border: #6a4d1b;
  --warning-text: #f6d38f;
  --danger-bg: #341a18;
  --danger-border: #7f332c;
  --danger-text: #f5b4ac;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #0f1317 0%, #11161b 240px, #0f1317 100%);
  color: var(--text);
}

body, button, input, select, textarea {
  font: inherit;
}

h1, h2, h3, p {
  margin: 0;
}

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

h1 {
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  font-size: 16px;
  line-height: 1.2;
}

.page {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px;
}

.stack {
  display: grid;
  gap: 14px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: start;
  padding: 18px 20px;
  margin-bottom: 16px;
  background: linear-gradient(180deg, rgba(29, 36, 43, 0.96), rgba(23, 29, 35, 0.96));
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}

.topbar > div:first-child {
  display: grid;
  gap: 6px;
}

.topbar .actions {
  display: grid;
  gap: 12px;
  justify-items: end;
  align-items: start;
}

.user-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: end;
}

.scrape-form {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.actions form {
  margin: 0;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

label {
  display: grid;
  gap: 6px;
  color: #c7d0d9;
  font-size: 13px;
  font-weight: 600;
}

input,
select,
textarea,
button,
.button {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(34, 197, 94, 0.24);
  outline-offset: 1px;
  border-color: rgba(34, 197, 94, 0.75);
}

textarea {
  padding: 10px 12px;
  resize: vertical;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-color: var(--accent-strong);
  background: linear-gradient(180deg, #1e7a3d, #166534);
  color: #f8fafc;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

button:hover,
.button:hover {
  transform: translateY(-1px);
  border-color: #34d399;
  box-shadow: 0 10px 20px rgba(22, 101, 52, 0.28);
}

button:active,
.button:active {
  transform: translateY(0);
}

.button.secondary,
.watch-modal-close,
.favorite-btn,
.favorite-toggle,
.admin-user-actions button,
.check-option {
  border-color: var(--border-strong);
  background: var(--surface-3);
  color: var(--text);
}

.button.secondary:hover,
.watch-modal-close:hover,
.favorite-btn:hover,
.favorite-toggle:hover,
.admin-user-actions button:hover {
  background: #27313a;
  border-color: #55616d;
  box-shadow: none;
}

.panel,
.filters,
.table-wrap,
.watch-modal-card,
.notice,
.run-errors,
.admin-user,
.auth-card {
  background: rgba(23, 29, 35, 0.96);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.panel,
.filters,
.table-wrap,
.watch-modal-card,
.auth-card {
  padding: 16px;
}

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

.filters {
  display: grid;
  grid-template-columns: minmax(190px, 0.95fr) minmax(190px, 0.95fr) minmax(220px, 1fr) minmax(220px, 1fr);
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.check-group {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  gap: 8px;
  min-height: 30px;
  margin: 0;
  padding: 0;
  border: 0;
}

.check-group legend {
  width: 100%;
  margin: 0 0 4px;
  color: #c7d0d9;
  font-size: 13px;
  font-weight: 700;
}

.check-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #e5e7eb;
}

.check-option input {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  margin: 0;
  border: 0;
  accent-color: var(--accent);
}

.model-check-group {
  grid-column: 1 / -1;
}

.source-filter-group { grid-column: 1; }
.type-filter-group { grid-column: 2; }
.brand-filter { grid-column: 3; }

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

  .topbar .actions {
    justify-items: start;
  }

  .scrape-form,
  .user-links {
    justify-items: start;
    justify-content: start;
  }

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

  .source-filter-group,
  .type-filter-group,
  .brand-filter,
  .model-check-group {
    grid-column: auto;
  }

  .model-check-group {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 16px;
  }

  h1 {
    font-size: 26px;
  }

  .filters {
    grid-template-columns: 1fr;
  }
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  color: #d5f7df;
  font-weight: 600;
}

.notice.error,
.run-errors {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
}

.scrape-status {
  display: grid;
  gap: 10px;
}

.scrape-status progress {
  width: 100%;
  height: 14px;
}

.run-errors {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
}

.run-errors h3 {
  font-size: 14px;
}

.run-errors ul {
  margin: 0;
  padding-left: 18px;
}

.run-errors li {
  margin: 4px 0;
  overflow-wrap: anywhere;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
}

.watch-create-form {
  display: grid;
  gap: 14px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 5px 7px 5px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.chip-disabled {
  opacity: 0.6;
}

.chip-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.chip-count {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #2a333d;
  color: #d7dde4;
  font-size: 12px;
  font-weight: 700;
}

.chip form {
  margin: 0;
}

.chip button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.watch-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
}

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

.watch-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 10, 13, 0.7);
}

.watch-modal-card {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.45);
}

.watch-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.watch-modal-header h3 {
  font-size: 20px;
}

.watch-modal-close {
  min-width: 40px;
  padding: 0;
  color: #dbe3ea;
  font-size: 24px;
  line-height: 1;
}

.watch-create-form .watch-brand-field,
.watch-create-form .watch-model-field {
  gap: 6px;
}

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

.watch-model-row input {
  min-width: 0;
}

.watch-model-row button {
  min-width: 44px;
  padding: 0 14px;
}

.watch-modal-hint {
  margin: -2px 0 0;
  font-size: 12px;
}

.watch-selected-models {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.watch-selected-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text);
  font-weight: 700;
}

.watch-hidden-models {
  display: none;
}

.watch-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.table-wrap {
  overflow-x: auto;
  padding: 0;
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(49, 59, 70, 0.7);
  text-align: left;
  vertical-align: middle;
}

th {
  color: #b7c0cb;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.listing-title {
  display: flex;
  gap: 12px;
  min-width: 280px;
}

.listing-title img {
  width: 74px;
  height: 54px;
  object-fit: cover;
  border-radius: 10px;
  background: #2a333d;
}

.listing-title a {
  color: #8be2ac;
  font-weight: 700;
  text-decoration: none;
}

.listing-title a:hover {
  text-decoration: underline;
}

.listing-title span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.listing-title .listing-import-summary {
  margin-top: 6px;
  color: #f6d38f;
  font-size: 12px;
  line-height: 1.35;
}

.empty {
  padding: 36px;
  text-align: center;
  color: var(--muted);
}

.favorite-btn {
  min-width: 40px;
  min-height: 40px;
  border-radius: 10px;
  color: #d7dde4;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.favorite-btn.favorite-active {
  background: #402b0a;
  border-color: #9a6b1f;
  color: #f8d87e;
}

.favorite-btn.favorite-active:hover {
  background: #53370d;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(520px, 100%);
}

.auth-card h1 {
  font-size: 28px;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.auth-form button {
  width: fit-content;
}

.admin-form {
  display: grid;
  gap: 14px;
}

.admin-form button {
  width: fit-content;
}

.admin-users {
  display: grid;
  gap: 12px;
}

.admin-user {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.admin-user-disabled {
  opacity: 0.62;
}

.admin-user-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}

.admin-user-meta strong {
  color: var(--text);
}

.admin-user-meta span {
  color: var(--muted);
}

.admin-user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-user-actions form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}

.admin-user-actions input {
  min-width: 240px;
}

.admin-create-footer {
  margin-top: 4px;
}

.admin-flag {
  width: fit-content;
}
