:root {
  --accent: #c9a227;
  --accent-dark: #a9871b;
  --bg: #eef1f5;
  --panel: #ffffff;
  --ink: #14171c;
  --muted: #6b7280;
  --line: #e2e6ec;
  --dark: #12151b;
  --danger: #d64545;
  --ok: #1f9d55;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(18, 21, 27, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- Login ---------- */
.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, #1e2430, #0c0e12 70%);
}
.login-card {
  width: 340px;
  background: #fff;
  padding: 32px;
  border-radius: 18px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4);
  text-align: center;
}
.login-card h1 { font-size: 20px; margin: 14px 0 4px; }
.login-card p { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  margin-bottom: 12px;
}
.login-card button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #1a1a1a;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.login-error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #7a5f10);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  letter-spacing: 1px;
}
.brand-mark.small { width: 38px; height: 38px; border-radius: 10px; font-size: 14px; }

/* ---------- Topbar ---------- */
.topbar {
  background: var(--dark);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-brand strong { display: block; font-size: 15px; }
.topbar-brand .muted { color: #9aa1ad; }
.topbar-actions { display: flex; gap: 8px; }

/* ---------- Layout ---------- */
.layout {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  gap: 20px;
}
.panel {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.panel-head h2 { font-size: 17px; margin: 0; }
.head-tools { display: flex; gap: 8px; align-items: center; }
.panel-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ---------- Forms ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.field > span { color: var(--muted); font-weight: 600; }
.field input,
.head-tools input[type="search"] {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  background: #fbfcfe;
  color: var(--ink);
  width: 100%;
}
.field input:focus, .head-tools input:focus { outline: 2px solid rgba(201, 162, 39, 0.4); border-color: var(--accent); }
.field input[type="color"] { padding: 4px; height: 42px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }
.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 13.5px;
  color: #3a404b;
  background: #f6f8fb;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  cursor: pointer;
}
.check input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--accent); flex: 0 0 auto; }

.btn {
  border: 1px solid transparent;
  background: var(--dark);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); }
.btn.accent { background: var(--accent); color: #1a1a1a; }
.btn.accent:hover { background: var(--accent-dark); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.topbar .btn.ghost { border-color: #333b47; color: #dfe3ea; }
.btn.ghost:hover { background: rgba(0, 0, 0, 0.05); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.status { font-size: 13px; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }

/* ---------- Scan bar ---------- */
.scan-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: #f6f8fb;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 16px;
}
.scan-bar .muted { margin-left: auto; }

/* ---------- Cars ---------- */
.cars {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.car {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  transition: 0.15s;
  position: relative;
  cursor: pointer;
}
.car:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.car.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.35); }
.car-thumb {
  height: 150px;
  background: #dfe3ea center/cover no-repeat;
  position: relative;
}
.car-thumb .no-photo {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #9aa1ad; font-size: 13px;
}
.car-check {
  position: absolute; top: 10px; right: 10px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: transparent;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.car.selected .car-check { background: var(--accent); color: #fff; }
.car-badge {
  position: absolute; top: 10px; left: 10px;
  background: rgba(18, 21, 27, 0.78);
  color: #fff; font-size: 12px; padding: 3px 9px; border-radius: 20px;
}
.car-body { padding: 12px; }
.car-body h3 { font-size: 15px; margin: 0 0 5px; line-height: 1.3; }
.car-summary { font-size: 12px; color: var(--muted); margin-bottom: 8px; line-height: 1.4; }
.car-specs { list-style: none; margin: 0 0 10px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 7px 12px; }
.car-specs li { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.car-specs li span { font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); font-weight: 700; }
.car-specs li b { font-size: 12.5px; font-weight: 600; color: var(--ink); word-break: break-word; }
.car-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.chip {
  font-size: 11px; padding: 3px 8px; border-radius: 20px;
  background: #f0f2f6; color: #49505c; font-weight: 600;
}
.car-price { font-weight: 800; font-size: 15px; }
.car-price small { display: block; font-weight: 600; color: var(--muted); font-size: 12px; }
.car-warn { color: var(--danger); font-size: 12px; margin-top: 6px; }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

/* ---------- Collections ---------- */
.collections { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.col-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #fff;
}
.col-card h3 { margin: 0 0 4px; font-size: 15px; }
.col-card .col-sub { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.col-link {
  display: flex; gap: 6px; align-items: center;
  background: #f6f8fb; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 8px; margin-bottom: 10px;
}
.col-link input { border: none; background: transparent; font-size: 12px; flex: 1; color: #49505c; }
.col-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(12, 14, 18, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-card {
  background: #fff; border-radius: 14px; width: 560px; max-width: 100%;
  max-height: 80vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head, .modal-foot {
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.modal-head { border-bottom: 1px solid var(--line); }
.modal-foot { border-top: 1px solid var(--line); }
.browse-path { padding: 10px 16px; font-size: 12px; color: var(--muted); word-break: break-all; }
.browse-list { overflow: auto; padding: 0 8px 8px; flex: 1; }
.browse-item {
  padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; gap: 8px;
}
.browse-item:hover { background: #f0f2f6; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--dark); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; opacity: 0; transition: 0.25s; z-index: 200; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.err { background: var(--danger); }

@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .layout { padding: 14px; }
}
