:root {
  --bg: #f4f7fb;
  --bg-alt: #edf3fb;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-strong: #ffffff;
  --surface-soft: #f5f8fd;
  --line: rgba(88, 113, 156, 0.14);
  --text: #1a2740;
  --muted: #63748d;
  --brand: #2890ff;
  --brand-strong: #215dd9;
  --accent: #28b57b;
  --warning: #ca8a19;
  --danger: #d66363;
  --shadow: 0 26px 50px rgba(47, 87, 151, 0.12);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: 'Manrope', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(40, 144, 255, 0.1), transparent 22%),
    radial-gradient(circle at bottom right, rgba(40, 181, 123, 0.08), transparent 20%),
    linear-gradient(180deg, #f8fbff 0%, #f1f6fc 46%, #edf3fb 100%);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(25, 36, 59, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(25, 36, 59, 0.03) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.7), transparent 88%);
}

.app-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at center, rgba(40, 144, 255, 0.06), transparent 32%),
    radial-gradient(circle at 75% 70%, rgba(40, 181, 123, 0.06), transparent 20%);
}

.page-shell {
  position: relative;
  max-width: 1460px;
  margin: 0 auto;
  padding: 22px 18px 40px;
}

.eyebrow,
.mini-label {
  margin: 0 0 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand);
}

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

.auth-screen {
  min-height: calc(100vh - 62px);
  display: grid;
  grid-template-columns: 1.1fr 420px;
  align-items: center;
  gap: 34px;
}

.auth-copy h1 {
  max-width: 11ch;
  font-size: clamp(2.8rem, 5.4vw, 5rem);
  line-height: 0.94;
  margin-bottom: 16px;
}

.auth-text,
.topbar-sub,
.widget-copy,
.overview-copy,
.status-copy,
.section-copy {
  color: var(--muted);
  line-height: 1.7;
}

.auth-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.auth-pills span,
.session-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(88, 113, 156, 0.12);
  font-weight: 700;
}

.auth-card,
.sidebar,
.overview-card,
.status-panel,
.info-card,
.vehicle-card,
.settings-card,
.placeholder-card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.auth-card {
  padding: 28px;
  border-radius: var(--radius-xl);
}

.auth-card-top,
.auth-tabs,
.crm-topbar,
.vehicle-head,
.settings-actions,
.status-row,
.hero-metrics,
.topbar-actions,
.summary-metrics,
.section-head {
  display: flex;
  gap: 14px;
}

.auth-card-top,
.crm-topbar,
.vehicle-head,
.status-row,
.section-head {
  justify-content: space-between;
  align-items: center;
}

.auth-tabs {
  margin: 18px 0;
  padding: 6px;
  border-radius: 999px;
  background: rgba(33, 93, 217, 0.06);
}

.tab-button,
.nav-item {
  border: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.tab-button {
  flex: 1;
  padding: 11px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 800;
}

.tab-button.active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(40, 144, 255, 0.18), rgba(33, 93, 217, 0.25));
}

.auth-form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}

input {
  width: 100%;
  border: 1px solid rgba(88, 113, 156, 0.16);
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  font: inherit;
}

button {
  border: 0;
  border-radius: 14px;
  padding: 13px 16px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  color: #ffffff;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  padding: 13px 16px;
  font: inherit;
  font-weight: 800;
  color: #ffffff;
  text-decoration: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
}

button:hover {
  transform: translateY(-1px);
}

button.secondary {
  background: linear-gradient(135deg, #436fd0, #2e4fa3);
}

button.ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(88, 113, 156, 0.14);
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.crm-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  min-height: calc(100vh - 62px);
}

.sidebar {
  border-radius: var(--radius-xl);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px;
  border-radius: 20px;
  background: var(--surface-soft);
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
}

.brand-name {
  margin-bottom: 4px;
  font-weight: 800;
}

.brand-copy,
.sidebar-user {
  color: var(--muted);
  margin-bottom: 0;
}

.sidebar-nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  color: var(--muted);
  font-weight: 800;
}

.nav-item.active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(40, 144, 255, 0.14), rgba(33, 93, 217, 0.12));
}

.nav-icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(40, 144, 255, 0.1);
  color: var(--brand-strong);
  font-size: 0.85rem;
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px;
  border-radius: 18px;
  background: var(--surface-soft);
}

.sidebar-logout {
  width: 100%;
  margin-top: 12px;
}

.crm-main {
  display: grid;
  gap: 18px;
}

.crm-topbar {
  padding: 6px 4px;
}

.crm-view {
  display: grid;
  gap: 18px;
}

.dashboard-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: 1.2fr 0.9fr;
}

.overview-card,
.status-panel,
.info-card,
.vehicle-card,
.settings-card,
.placeholder-card {
  border-radius: var(--radius-xl);
  padding: 22px;
}

.overview-card-primary {
  position: relative;
  overflow: hidden;
}

.overview-card-primary::after {
  content: '';
  position: absolute;
  right: -44px;
  top: -44px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(40, 144, 255, 0.12), transparent 70%);
}

.hero-metrics,
.summary-metrics,
.settings-grid,
.dashboard-cards {
  flex-wrap: wrap;
}

.hero-metric,
.summary-metric {
  flex: 1 1 calc(50% - 10px);
  min-width: 150px;
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--surface-soft);
  border: 1px solid rgba(88, 113, 156, 0.08);
}

.hero-metric span,
.summary-metric span {
  display: block;
  color: var(--muted);
  margin-bottom: 6px;
}

.hero-metric strong,
.widget-value,
.summary-metric strong {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(1.4rem, 4vw, 2.1rem);
}

.status-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.status-list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed rgba(88, 113, 156, 0.14);
  color: var(--muted);
}

.status-list-item strong {
  color: var(--text);
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #b1bfd3;
  box-shadow: 0 0 0 8px rgba(117, 138, 168, 0.14);
}

.status-dot.online {
  background: var(--accent);
  box-shadow: 0 0 0 8px rgba(40, 181, 123, 0.14);
}

.dashboard-cards,
.settings-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.settings-card-wide {
  grid-column: 1 / -1;
}

.module-metrics {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.record-list {
  display: grid;
  gap: 16px;
}

.compact-list {
  margin-top: 18px;
}

.record-card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-xl);
  padding: 20px;
}

.compact-record {
  padding: 18px;
}

.record-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.record-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.record-subtitle {
  color: var(--muted);
  margin-bottom: 0;
}

.record-pill {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text);
  background: rgba(88, 113, 156, 0.1);
}

.record-pill.online {
  color: var(--accent);
  background: rgba(40, 181, 123, 0.12);
}

.record-pill.warning {
  color: var(--warning);
  background: rgba(202, 138, 25, 0.12);
}

.record-grid,
.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.form-grid-span {
  grid-column: 1 / -1;
}

.record-stat {
  padding: 14px;
  border-radius: 18px;
  background: var(--surface-soft);
  border: 1px solid rgba(88, 113, 156, 0.08);
}

.record-stat span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.record-stat strong {
  font-size: 1rem;
}

.settings-form {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.vehicle-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}

.vehicle-card {
  display: grid;
  gap: 18px;
  position: relative;
  overflow: hidden;
}

.vehicle-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(40, 144, 255, 0.06), transparent 36%);
  pointer-events: none;
}

.vehicle-name {
  font-size: 1.38rem;
  margin-bottom: 6px;
}

.vehicle-meta,
.empty-state {
  color: var(--muted);
  margin-bottom: 0;
}

.vehicle-pill {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
}

.vehicle-pill.online {
  color: var(--accent);
  background: rgba(40, 181, 123, 0.12);
}

.vehicle-pill.warning {
  color: var(--warning);
  background: rgba(202, 138, 25, 0.12);
}

.vehicle-visual {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
  align-items: center;
}

.car-stage {
  min-height: 160px;
  border-radius: 24px;
  position: relative;
  background:
    radial-gradient(circle at center, rgba(40, 144, 255, 0.1), transparent 56%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(242, 247, 252, 0.94));
  border: 1px solid rgba(88, 113, 156, 0.08);
  overflow: hidden;
}

.car-stage::after {
  content: '';
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 28px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(20, 32, 51, 0.1), transparent);
}

.photo-button {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  background: rgba(255, 255, 255, 0.92);
  color: var(--brand-strong);
  border: 1px solid rgba(88, 113, 156, 0.12);
  box-shadow: 0 8px 18px rgba(34, 70, 122, 0.14);
}

.signal-ring {
  position: absolute;
  width: 96px;
  height: 96px;
  right: 12px;
  top: 14px;
  border-radius: 50%;
  border: 1px solid rgba(40, 144, 255, 0.12);
}

.signal-ring::before,
.signal-ring::after {
  content: '';
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  border: 1px solid rgba(40, 144, 255, 0.12);
}

.signal-ring::after {
  inset: 22px;
}

.vehicle-photo {
  position: absolute;
  inset: 8px 10px 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.vehicle-photo img {
  width: 112%;
  max-width: none;
  height: auto;
  transform: translateY(6px);
  filter: drop-shadow(0 18px 20px rgba(35, 54, 88, 0.12));
}

.vehicle-photo.custom-photo {
  inset: 16px 18px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
}

.vehicle-photo.custom-photo img {
  display: block;
  width: auto !important;
  height: 100%;
  max-height: 140px;
  max-width: 100%;
  transform: none;
  filter: drop-shadow(0 12px 16px rgba(35, 54, 88, 0.1));
}

.vehicle-photo.model-3 img {
  width: 108%;
  transform: translate(-2%, 4px);
}

.vehicle-photo.model-3-legacy img {
  width: 94%;
  transform: translate(-1%, 6px);
}

.vehicle-photo.model-3-refresh img {
  width: 108%;
  transform: translate(-2%, 4px);
}

.vehicle-photo.model-y img {
  width: 114%;
  transform: translate(-1%, 6px);
}

.vehicle-photo.model-s img {
  width: 114%;
  transform: translate(-2%, 4px);
}

.vehicle-photo.model-x img {
  width: 115%;
  transform: translate(-2%, 3px);
}

.vehicle-photo.model-generic img {
  width: 114%;
}

.stat-orb {
  display: grid;
  place-items: center;
  width: 138px;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(40, 144, 255, 0.18), rgba(255, 255, 255, 0.92) 58%, rgba(233, 241, 249, 0.96) 72%);
  border: 1px solid rgba(40, 144, 255, 0.12);
}

.stat-orb strong {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
}

.stat-orb span {
  color: var(--muted);
  font-size: 0.9rem;
}

.progress-list,
.vehicle-stats {
  display: grid;
  gap: 12px;
}

.progress-item {
  display: grid;
  gap: 7px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(40, 144, 255, 0.08);
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-strong), var(--brand), var(--accent));
}

.vehicle-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.vehicle-stat {
  padding: 14px;
  border-radius: 18px;
  background: var(--surface-soft);
  border: 1px solid rgba(88, 113, 156, 0.08);
}

.vehicle-stat span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.vehicle-stat strong {
  font-size: 1.05rem;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  padding: 15px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.97);
  color: var(--text);
  box-shadow: 0 22px 45px rgba(34, 70, 122, 0.18);
  border: 1px solid rgba(88, 113, 156, 0.12);
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .crm-shell,
  .dashboard-grid,
  .settings-grid,
  .dashboard-cards,
  .auth-screen {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 2;
  }
}

@media (max-width: 920px) {
  .vehicle-visual,
  .vehicle-stats {
    grid-template-columns: 1fr;
  }

  .record-head {
    display: grid;
  }

  .crm-topbar,
  .section-head,
  .topbar-actions,
  .status-row,
  .settings-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

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

  .vehicle-grid,
  .dashboard-cards,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .hero-metric,
  .summary-metric {
    flex-basis: 100%;
  }
}
