/* Vehicle Catalogue dashboard - modern dark theme. */

:root {
  --bg: #0c0e13;
  --bg-elev: #14171f;
  --bg-elev-2: #1b1f2a;
  --panel: #131722;
  --panel-border: #232838;
  --text: #e7e9ee;
  --text-dim: #9aa0ad;
  --text-faint: #6b7280;
  --accent: #4f8cff;
  --accent-strong: #3b82f6;
  --danger: #e23b3b;
  --ok: #3bb273;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --radius-sm: 9px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(79, 140, 255, 0.10), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(155, 93, 229, 0.08), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  user-select: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.08);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #5d98ff 0%, #4787f5 100%);
}

.btn-ghost {
  background: var(--bg-elev-2);
  color: var(--text-dim);
  border-color: var(--panel-border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: #34394c;
}

/* ---------- login ---------- */

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-wrap {
  width: 100%;
  max-width: 380px;
}

.login-card {
  background: linear-gradient(180deg, var(--bg-elev) 0%, var(--panel) 100%);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-brand {
  text-align: center;
  margin-bottom: 6px;
}

.login-logo {
  display: inline-block;
  font-size: 38px;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 8px;
}

.login-title {
  font-size: 21px;
}

.login-sub {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 13px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.field-input {
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 13px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-input::placeholder {
  color: #4c5263;
}

.field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.18);
}

.login-submit {
  margin-top: 4px;
  width: 100%;
  padding: 12px 16px;
}

.login-foot {
  margin: 4px 0 0;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: rgba(12, 14, 19, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--panel-border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 13px;
}

.topbar-logo {
  font-size: 26px;
  color: var(--accent);
  line-height: 1;
}

.topbar-titles {
  display: flex;
  flex-direction: column;
}

.topbar-title {
  font-size: 17px;
}

.topbar-sub {
  font-size: 12px;
  color: var(--text-dim);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--bg-elev-2);
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
}

.live-pill .live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
}

.live-pill.is-live {
  color: #ffd9d9;
  border-color: rgba(226, 59, 59, 0.5);
  background: rgba(226, 59, 59, 0.12);
}

.live-pill.is-live .live-dot {
  background: var(--danger);
  box-shadow: 0 0 0 0 rgba(226, 59, 59, 0.6);
  animation: pulse 1.6s infinite;
}

.live-pill.is-offline {
  color: var(--text-faint);
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(226, 59, 59, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(226, 59, 59, 0); }
  100% { box-shadow: 0 0 0 0 rgba(226, 59, 59, 0); }
}

/* ---------- layout ---------- */

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px 22px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel {
  background: linear-gradient(180deg, var(--bg-elev) 0%, var(--panel) 100%);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title {
  font-size: 16px;
}

.panel-hint {
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------- live feed (popup-style main panel) ---------- */

.live-panel {
  padding: 16px;
}

.video-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02), 0 14px 40px rgba(0, 0, 0, 0.5);
}

.live-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.video-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at center, rgba(20, 23, 31, 0.55), rgba(0, 0, 0, 0.85));
  backdrop-filter: blur(2px);
}

.video-overlay-text {
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(12, 14, 19, 0.6);
}

/* ---------- active source label (live feed) ---------- */

.active-source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #d8e4ff;
  background: rgba(79, 140, 255, 0.14);
  border: 1px solid rgba(79, 140, 255, 0.4);
}

/* ---------- sources / sections ---------- */

.add-source-form {
  margin-bottom: 16px;
}

.add-source-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.add-source-url {
  flex: 2 1 260px;
  min-width: 0;
}

.add-source-label {
  flex: 1 1 160px;
  min-width: 0;
}

.add-source-submit {
  flex: 0 0 auto;
  white-space: nowrap;
}

.add-source-submit:disabled {
  opacity: 0.6;
  cursor: default;
}

.add-source-msg {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}

.add-source-msg.is-error {
  color: var(--danger);
}

.sections-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.section-item:hover {
  border-color: #34394c;
}

.section-item.is-selected {
  border-color: var(--accent);
  background: rgba(79, 140, 255, 0.10);
}

.section-main {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.section-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52vw;
}

.section-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.section-count {
  min-width: 26px;
  text-align: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--panel-border);
}

.section-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid transparent;
}

.section-badge-pending {
  color: #f2c537;
  background: rgba(242, 197, 55, 0.12);
  border-color: rgba(242, 197, 55, 0.35);
}

.section-badge-processing {
  color: #d8e4ff;
  background: rgba(79, 140, 255, 0.14);
  border-color: rgba(79, 140, 255, 0.4);
}

.section-badge-done {
  color: var(--ok);
  background: rgba(59, 178, 115, 0.12);
  border-color: rgba(59, 178, 115, 0.35);
}

.section-badge-error {
  color: #ffb4b4;
  background: rgba(226, 59, 59, 0.12);
  border-color: rgba(226, 59, 59, 0.4);
}

/* ---------- stats ---------- */

.stat-total-wrap {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

.stat-total-label {
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-total {
  font-size: 22px;
  font-weight: 750;
  color: var(--text);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.stats-heading {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin-bottom: 10px;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--panel-border);
  font-size: 13px;
  color: var(--text);
}

.chip-empty {
  color: var(--text-faint);
  font-style: italic;
}

.chip-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  flex: 0 0 auto;
}

.chip-label {
  color: var(--text-dim);
}

.chip-count {
  font-weight: 700;
  color: var(--text);
}

/* ---------- gallery grid ---------- */

.gallery-panel {
  position: relative;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.gallery-empty {
  color: var(--text-faint);
  font-size: 14px;
  text-align: center;
  padding: 26px 10px 6px;
  margin: 0;
}

.card {
  background: var(--bg-elev-2);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: #34394c;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.45);
}

.card-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #0a0c11;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-thumb-missing {
  background: repeating-linear-gradient(
    45deg,
    #14171f,
    #14171f 10px,
    #171b25 10px,
    #171b25 20px
  );
}

.card-thumb-fallback {
  color: var(--text-faint);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card-color-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(4px);
}

.card-color-swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  flex: 0 0 auto;
}

.card-color-name {
  font-size: 12px;
  font-weight: 600;
  color: #f2f3f6;
}

.card-body {
  padding: 11px 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-class {
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
}

.card-conf {
  font-size: 11px;
  font-weight: 700;
  color: var(--ok);
  background: rgba(59, 178, 115, 0.12);
  border: 1px solid rgba(59, 178, 115, 0.3);
  border-radius: 999px;
  padding: 2px 7px;
}

.card-uid {
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--accent);
}

.card-time {
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------- footer ---------- */

.footer {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 22px 30px;
  color: var(--text-faint);
  font-size: 12px;
  text-align: center;
}

/* ---------- responsive ---------- */

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

  .topbar-sub {
    display: none;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .layout {
    padding: 16px 14px 32px;
  }
}
