/* =============================================================
   ONYX Admin — Design System (v2 — matched to customer site)
   amber on slate-dark · Inter + Bebas Neue
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Bebas+Neue&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* ---- Surfaces (slate dark) ---- */
  --bg-base: #0f172a;
  --bg-elevated: #1e293b;
  --bg-raised: #334155;
  --bg-deep: #020617;

  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.25);
  --border-faint: rgba(148, 163, 184, 0.06);

  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  /* ---- Brand: brand red (matches logo hexagon) ---- */
  --amber: #ef4444;
  --amber-light: #f87171;
  --amber-deep: #dc2626;
  --amber-glow: rgba(239, 68, 68, 0.22);
  --amber-soft: rgba(239, 68, 68, 0.08);

  /* ---- Status ---- */
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --info: #60a5fa;
  --info-bg: rgba(96, 165, 250, 0.12);

  /* ---- Typography ---- */
  --font-display: 'Bebas Neue', 'Inter', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* ---- Shadows ---- */
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.5);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  --sidebar-width: 260px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 999px;
}

/* =============================================================
   Light theme overrides
   ============================================================= */
[data-theme="light"] {
  /* Surfaces */
  --bg-base: #f8fafc;          /* slate-50 — page bg */
  --bg-elevated: #ffffff;       /* cards, topbar */
  --bg-raised: #f1f5f9;         /* row hover */
  --bg-deep: #e2e8f0;           /* sidebar, table head */

  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.18);
  --border-faint: rgba(15, 23, 42, 0.05);

  /* Text */
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  /* Brand: deeper red for contrast on light */
  --amber: #dc2626;
  --amber-light: #ef4444;
  --amber-deep: #b91c1c;
  --amber-glow: rgba(220, 38, 38, 0.22);
  --amber-soft: rgba(220, 38, 38, 0.08);

  /* Status backgrounds slightly more saturated for legibility on white */
  --success-bg: rgba(16, 185, 129, 0.14);
  --danger-bg: rgba(239, 68, 68, 0.14);
  --warning-bg: rgba(245, 158, 11, 0.14);
  --info-bg: rgba(96, 165, 250, 0.14);

  /* Lighter shadows */
  --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 12px 32px rgba(15, 23, 42, 0.1);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--bg-raised); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--amber); }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.55;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* =============================================================
   Layout shell
   ============================================================= */
.admin-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

@media (max-width: 900px) { .admin-shell { grid-template-columns: 1fr; } }

.sidebar {
  background: var(--bg-deep);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed; inset: 0; z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease-out);
    width: 280px; height: 100vh;
  }
  .sidebar.open { transform: translateX(0); }
}

.sidebar-brand {
  padding: 1.5rem 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.brand-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  line-height: 1;
}

.brand-logo-img {
  height: 36px;
  width: auto;
  display: block;
  max-width: 100%;
}

/* Theme-aware swap: white-text logo on dark, dark-text on light.
   !important is used because other selectors (.auth-logo-img,
   .brand-logo-img, .nav-logo-img) set display: block, and they appear
   later in the cascade. The swap MUST win regardless of source order. */
.logo-light { display: none !important; }
[data-theme="light"] .logo-dark { display: none !important; }
[data-theme="light"] .logo-light { display: block !important; }

.sidebar-nav { list-style: none; flex: 1; padding: 1rem 0.85rem; }
.sidebar-nav li { margin-bottom: 0.15rem; }

.sidebar-nav a,
.sidebar-nav button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all 0.2s var(--ease-out);
  width: 100%;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav a:hover,
.sidebar-nav button:hover {
  background: var(--amber-soft);
  color: var(--amber-light);
}

.sidebar-nav a.active,
.sidebar-nav button.active {
  background: var(--amber);
  color: #fff;
  font-weight: 600;
}

.sidebar-nav .icon,
.sidebar-nav .nav-icon,
.sidebar-nav svg {
  width: 18px !important;
  height: 18px !important;
  flex-shrink: 0;
  stroke-width: 1.7;
}

.sidebar-section-title {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 1.25rem 0.85rem 0.5rem;
  list-style: none;
}

.sidebar-foot {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--amber);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--amber);
  margin-top: 0.1rem;
}

.main {
  background: var(--bg-base);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }

.topbar-link {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: color 0.2s;
}

.topbar-link:hover { color: var(--amber-light); }

.menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  padding: 0;
}

@media (max-width: 900px) { .menu-toggle { display: inline-flex; } }

.content { flex: 1; padding: 2rem; }

@media (max-width: 700px) {
  .content { padding: 1.25rem; }
  .topbar { padding: 0.75rem 1.25rem; }
}

.page-title { margin-bottom: 2rem; }

.page-title h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.8rem);
  letter-spacing: 0.02em;
  line-height: 1;
  margin-bottom: 0.4rem;
}

.page-title h1 .accent { color: var(--amber); }

.page-title p { color: var(--text-muted); font-size: 0.95rem; }

/* =============================================================
   Section
   ============================================================= */
.section { margin-bottom: 2rem; }

.section-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title::before {
  content: '';
  width: 24px; height: 1px;
  background: var(--amber);
}

.spacer { flex: 1; }

/* =============================================================
   Buttons
   ============================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.35rem;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  white-space: nowrap;
  text-decoration: none;
  background: transparent;
  color: inherit;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

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

.btn-primary:hover:not(:disabled) {
  background: var(--amber-light);
  border-color: var(--amber-light);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px var(--amber-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--amber);
  color: var(--amber-light);
  background: var(--amber-soft);
}

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
  border-color: #dc2626;
  transform: translateY(-1px);
}

.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.78rem; }
.btn-block { width: 100%; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.2s var(--ease-out);
}

.icon-btn:hover {
  border-color: var(--amber);
  color: var(--amber-light);
  background: var(--amber-soft);
}

.icon-btn.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-bg);
}

.icon-btn svg { width: 16px; height: 16px; }

/* =============================================================
   Card
   ============================================================= */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 1rem;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.02em;
  line-height: 1;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

/* =============================================================
   Stats grid
   ============================================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  transition: all 0.3s var(--ease-out);
}

.stat-card:hover {
  border-color: var(--amber);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2.2rem;
  letter-spacing: 0.02em;
  color: var(--amber-light);
  line-height: 1;
  margin-bottom: 0.4rem;
}

.stat-change {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* =============================================================
   Pills / tags / status badges
   ============================================================= */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
}

.pill-gold {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: var(--amber-glow);
}

.pill-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.3);
}

.pill-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.3);
}

.pill-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.pill-info {
  background: var(--info-bg);
  color: var(--info);
  border-color: rgba(96, 165, 250, 0.3);
}

.tag-list { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.tag-remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.tag-remove:hover { color: var(--danger); }

/* =============================================================
   Forms
   ============================================================= */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
}

.field label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.field input,
.field select,
.field textarea {
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 0.7rem 0.9rem;
  font-size: 0.92rem;
  border-radius: var(--radius-sm);
  outline: none;
  transition: all 0.2s var(--ease-out);
  width: 100%;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-soft);
}

.field select option { background: var(--bg-elevated); color: var(--text-primary); }
.field textarea { resize: vertical; min-height: 100px; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 600px) { .field-row { grid-template-columns: 1fr; } }

.field-error { font-size: 0.78rem; color: var(--danger); margin-top: 0.25rem; }

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0;
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.checkbox input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--amber);
  cursor: pointer;
}

/* =============================================================
   Toolbar / search / filters
   ============================================================= */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 220px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 0.65rem 0.95rem;
  font-size: 0.92rem;
  border-radius: var(--radius-sm);
  outline: none;
}

.search-input:focus { border-color: var(--amber); }

.filter-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 0.65rem 0.95rem;
  font-size: 0.88rem;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
}

.filter-select:focus { border-color: var(--amber); }
.filter-select option { background: var(--bg-elevated); }

/* =============================================================
   Tables (admin inventory)
   ============================================================= */
.table-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.table-wrap thead {
  background: var(--bg-deep);
}

.table-wrap th {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--amber);
  padding: 0.95rem 1.1rem;
  text-align: left;
  white-space: nowrap;
}

.table-wrap td {
  padding: 1rem 1.1rem;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.92rem;
  vertical-align: middle;
}

.table-wrap tbody tr {
  transition: background 0.2s var(--ease-out);
}

.table-wrap tbody tr:hover {
  background: var(--bg-raised);
}

/* car-row-cell is the wrapper INSIDE the Vehicle <td> (image + title group) */
.car-row-cell {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 220px;
}

.car-row-img {
  width: 80px;
  height: 60px;
  background: var(--bg-deep);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}

.car-row-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.car-row-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 0.2rem;
}

.car-row-sub {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  justify-content: flex-end;
}

/* Make the Actions column right-aligned to match its header */
.table-wrap td:last-child {
  text-align: right;
  white-space: nowrap;
}

/* Numeric columns (year, km, views) feel tidier centered or with their
   own neutral alignment — keep them left-aligned but compact */
.table-wrap td:nth-child(2),
.table-wrap td:nth-child(3),
.table-wrap td:nth-child(6) {
  white-space: nowrap;
  color: var(--text-secondary);
}

/* Mobile: collapse table into stacked cards */
@media (max-width: 800px) {
  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
    width: 100%;
  }

  .table-wrap thead { display: none; }

  .table-wrap tbody tr {
    padding: 1rem;
    border-top: 1px solid var(--border);
  }

  .table-wrap td {
    border: none;
    padding: 0.3rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  /* Vehicle cell stays the full-width hero of each card */
  .table-wrap td:first-child {
    padding-bottom: 0.75rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-faint);
  }

  /* Label each cell with its column name on mobile */
  .table-wrap td:nth-child(2)::before { content: 'YEAR'; }
  .table-wrap td:nth-child(3)::before { content: 'KM'; }
  .table-wrap td:nth-child(4)::before { content: 'PRICE'; }
  .table-wrap td:nth-child(5)::before { content: 'STATUS'; }
  .table-wrap td:nth-child(6)::before { content: 'VIEWS'; }
  .table-wrap td:nth-child(7)::before { content: 'ACTIONS'; }

  .table-wrap td:not(:first-child)::before {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--text-muted);
  }
}

/* =============================================================
   Image uploader / image tiles
   ============================================================= */
.uploader {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  background: var(--bg-base);
  transition: all 0.2s var(--ease-out);
  cursor: pointer;
}

.uploader:hover,
.uploader.dragging {
  border-color: var(--amber);
  background: var(--amber-soft);
}

.uploader p { color: var(--text-muted); margin-top: 0.5rem; }
.uploader strong { color: var(--amber-light); font-weight: 600; }

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
}

.image-tile {
  position: relative;
  aspect-ratio: 4/3;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.image-tile img { width: 100%; height: 100%; object-fit: cover; }

.image-tile-actions {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  display: flex;
  gap: 0.3rem;
  opacity: 0;
  transition: opacity 0.2s var(--ease-out);
}

.image-tile:hover .image-tile-actions { opacity: 1; }

.image-tile-cover-badge {
  position: absolute;
  bottom: 0.4rem;
  left: 0.4rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  background: var(--amber);
  color: #fff;
  border-radius: var(--radius-full);
}

.image-tile-upload {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bg-elevated);
  border: 2px dashed var(--border-strong);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: all 0.2s var(--ease-out);
}

.image-tile-upload:hover {
  border-color: var(--amber);
  color: var(--amber-light);
  background: var(--amber-soft);
}

.image-tile-upload svg { width: 28px; height: 28px; }

.upload-progress-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.4);
}

.upload-progress-fill {
  height: 100%;
  background: var(--amber);
  transition: width 0.2s ease-out;
}

/* =============================================================
   Tile button (dashboard quick actions)
   ============================================================= */
.tile-btn {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  text-align: left;
  transition: all 0.25s var(--ease-out);
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
}

.tile-btn:hover {
  border-color: var(--amber);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.tile-btn .tile-icon {
  width: 32px; height: 32px;
  color: var(--amber);
  margin-bottom: 0.25rem;
}

.tile-btn strong {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  display: block;
  margin-bottom: 0.2rem;
}

.tile-btn span { color: var(--text-muted); font-size: 0.82rem; }

/* =============================================================
   Modal
   ============================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s var(--ease-out), visibility 0.2s var(--ease-out);
}

.modal-backdrop.open { opacity: 1; visibility: visible; }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 2rem;
  max-width: 460px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.3s var(--ease-out);
}

.modal-backdrop.open .modal { transform: translateY(0); }

.modal h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 0.02em;
  margin-bottom: 0.6rem;
}

.modal p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
}

/* =============================================================
   Toast
   ============================================================= */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.2rem;
  font-size: 0.88rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s var(--ease-out);
  min-width: 240px;
}

.toast.success { border-left-color: var(--success); }
.toast.error, .toast.danger { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--info); }

.toast.out { animation: toastOut 0.3s var(--ease-out) forwards; }

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

@media (max-width: 600px) {
  .toast-container { left: 1rem; right: 1rem; bottom: 1rem; }
  .toast { min-width: 0; }
}

/* =============================================================
   Loading + Empty
   ============================================================= */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 4rem 2rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.spinner, .spinner-lg {
  border: 2px solid var(--border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner { width: 16px; height: 16px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 4rem 2rem; color: var(--text-muted); }

.empty-icon {
  width: 56px; height: 56px;
  margin: 0 auto 1.25rem;
  color: var(--text-faint);
  opacity: 0.6;
}

.empty h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.empty p {
  font-size: 0.92rem;
  max-width: 360px;
  margin: 0 auto 1.25rem;
  line-height: 1.6;
}

/* =============================================================
   Setup banner
   ============================================================= */
.setup-banner {
  background: var(--amber-soft);
  border-left: 3px solid var(--amber);
  padding: 1rem 1.5rem;
  margin: 1rem;
  border-radius: var(--radius-sm);
}

.setup-banner strong {
  color: var(--amber-light);
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.setup-banner span, .setup-banner p {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.setup-banner code {
  background: var(--bg-deep);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  color: var(--amber-light);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.setup-banner a { color: var(--amber-light); text-decoration: underline; }

/* =============================================================
   Auth (login) page
   ============================================================= */
.auth-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

@media (max-width: 900px) { .auth-layout { grid-template-columns: 1fr; } }

.auth-art {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3rem;
  overflow: hidden;
  color: #f1f5f9;
  background: var(--bg-deep);
}

/* Auth art background: video element (with photo poster fallback) */
.auth-art-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  /* Subtle scale lets the video bleed past edges so it always fills */
  transform: scale(1.02);
}

/* Photo fallback layer — only shows if the video tag is missing (e.g.
   in some screen readers / no-JS scenarios). The video's own `poster`
   attribute handles the still-loading state for most users. */
.auth-art::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url('auth-hero.jpg') center/cover no-repeat;
  z-index: 0;
}

.auth-art:has(.auth-art-video)::after { display: none; }

@media (prefers-reduced-motion: reduce) {
  .auth-art-video { display: none; }
  /* If user prefers reduced motion, fall back to the static photo */
  .auth-art:has(.auth-art-video)::after { display: block; }
}

@media (max-width: 900px) { .auth-art { display: none; } }

/* Dark gradient overlay — between photo layer and content layer.
   Darker on the left where text sits, lighter on the right so car shows. */
.auth-art::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      105deg,
      rgba(15, 23, 42, 0.92) 0%,
      rgba(15, 23, 42, 0.7) 35%,
      rgba(2, 6, 23, 0.5) 70%,
      rgba(2, 6, 23, 0.85) 100%
    ),
    radial-gradient(
      ellipse at 25% 30%,
      rgba(245, 158, 11, 0.15),
      transparent 55%
    );
  z-index: 1;
  pointer-events: none;
}

.auth-art > *:not(.auth-art-video) {
  position: relative;
  z-index: 2;
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  line-height: 1;
}

.auth-logo-img {
  height: 42px;
  width: auto;
  display: block;
  max-width: 100%;
}

.auth-art h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 0.95;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.auth-art h2 .accent { color: var(--amber); }

.auth-art p {
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 380px;
}

.auth-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
}

.auth-form { width: 100%; max-width: 380px; }

.auth-form h1 {
  font-family: var(--font-display);
  font-size: 2.2rem;
  letter-spacing: 0.02em;
  margin-bottom: 0.4rem;
}

.auth-form h1 .accent { color: var(--amber); }

.auth-form > p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 2rem;
}

.auth-demo {
  background: var(--amber-soft);
  border: 1px solid var(--amber-glow);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.auth-demo strong {
  display: block;
  color: var(--amber-light);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.auth-demo code {
  background: var(--bg-deep);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  color: var(--amber-light);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

/* =============================================================
   Utility
   ============================================================= */
.text-muted { color: var(--text-muted); }
.text-amber { color: var(--amber-light); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

/* =============================================================
   Theme toggle
   ============================================================= */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
}

.theme-toggle:hover {
  border-color: var(--amber);
  color: var(--amber-light);
  transform: rotate(15deg);
}

.theme-toggle svg { width: 16px; height: 16px; }

/* Show moon in dark mode, sun in light mode */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* =============================================================
   Light-mode polish — small adjustments for things that need
   different treatment when colors flip
   ============================================================= */

/* The amber sidebar nav active state — improve contrast on light */
[data-theme="light"] .sidebar-nav a.active,
[data-theme="light"] .sidebar-nav button.active {
  background: var(--amber);
  color: #fff;
}

/* Primary button text contrast on light theme (deeper amber bg) */
[data-theme="light"] .btn-primary {
  color: #fff;
}

[data-theme="light"] .car-card-tag.featured,
[data-theme="light"] .pill-gold {
  color: #fff;
}

/* Status pills get fuller backgrounds in light mode for legibility */
[data-theme="light"] .pill-success {
  background: rgba(16, 185, 129, 0.18);
  color: #047857;
}

[data-theme="light"] .pill-warning {
  background: rgba(245, 158, 11, 0.18);
  color: #b45309;
}

[data-theme="light"] .pill-danger {
  background: rgba(239, 68, 68, 0.18);
  color: #b91c1c;
}

[data-theme="light"] .pill-info {
  background: rgba(96, 165, 250, 0.18);
  color: #1d4ed8;
}

/* Image tile placeholders look better with subtle gray on light */
[data-theme="light"] .car-row-img {
  background: var(--bg-raised);
}

/* Auth split — stays dark and moody in both themes so the photo is
   the visual hero and text stays legible. Light mode just tweaks the
   overlay slightly. */
[data-theme="light"] .auth-art::before {
  background:
    linear-gradient(
      105deg,
      rgba(15, 23, 42, 0.94) 0%,
      rgba(15, 23, 42, 0.72) 35%,
      rgba(2, 6, 23, 0.55) 70%,
      rgba(2, 6, 23, 0.88) 100%
    ),
    radial-gradient(
      ellipse at 25% 30%,
      rgba(245, 158, 11, 0.18),
      transparent 55%
    );
}

[data-theme="light"] .auth-art { color: #f1f5f9; }
[data-theme="light"] .auth-art h2 { color: #f1f5f9; }
[data-theme="light"] .auth-art p { color: #cbd5e1; }
[data-theme="light"] .auth-art .brand-title { color: #f1f5f9; }

/* =============================================================
   Utility (margin)
   ============================================================= */
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

/* Floating theme toggle for login page */
.theme-toggle-floating {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 50;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.theme-toggle-floating:hover {
  transform: rotate(15deg);
  box-shadow: var(--shadow-md);
}

/* =============================================================
   LEADS PAGE — tabs, customer cells, modal, nav badge
   ============================================================= */

/* Tab bar at the top of the leads page */
.lead-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.lead-tab {
  background: transparent;
  border: none;
  padding: 0.85rem 1.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: color 0.2s var(--ease-out);
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
}

.lead-tab:hover {
  color: var(--text-primary);
}

.lead-tab.active {
  color: var(--amber);
  border-bottom-color: var(--amber);
}

.lead-tab-count {
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  min-width: 22px;
  text-align: center;
}

.lead-tab.active .lead-tab-count {
  background: var(--amber-soft);
  color: var(--amber);
}

/* Toolbar above the table */
.lead-toolbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.lead-toolbar > .input { flex: 1; min-width: 220px; }

.lead-result-count {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--font-mono, monospace);
  margin-left: auto;
}

/* Customer + Car cell layouts */
.lead-customer,
.lead-car {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 160px;
}

.lead-customer strong,
.lead-car strong {
  color: var(--text-primary);
  font-size: 0.95rem;
}

.lead-contact {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: var(--font-mono, monospace);
}

.lead-contact-soft {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.lead-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lead-message {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 320px;
  line-height: 1.4;
}

/* Sidebar nav badge for "new" lead count */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--amber);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  min-width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  padding: 0 0.4rem;
  margin-left: auto;
}

.sidebar-nav a {
  /* So the badge can push to the far right */
  justify-content: flex-start;
}

.sidebar-nav a .nav-badge { margin-left: auto; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(6px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* Lead detail definition list inside modal */
.lead-detail {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 0.5rem 1.25rem;
  margin: 0;
}

.lead-detail dt {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-top: 0.25rem;
}

.lead-detail dd {
  margin: 0;
  color: var(--text-primary);
  font-size: 0.92rem;
  line-height: 1.5;
}

.lead-detail dd a {
  color: var(--amber);
  text-decoration: none;
}

.lead-detail dd a:hover { text-decoration: underline; }

/* Danger button for delete actions in the modal */
.btn-danger {
  background: var(--danger);
  color: #fff;
  border: 1px solid var(--danger);
}

.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

/* Empty state polish */
.empty {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-icon {
  display: inline-flex;
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  background: var(--bg-raised);
  border-radius: var(--radius-full);
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.empty h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin: 0 0 0.4rem;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.empty p {
  margin: 0;
  color: var(--text-muted);
  max-width: 420px;
  margin: 0 auto;
}
