/* ==========================================================================
   AutoNext Car Market - Admin Portal Stylesheet
   --------------------------------------------------------------------------
   NOTE: Google Fonts used to be loaded via @import here. That blocked the
   whole stylesheet on a second network round-trip to fonts.googleapis.com,
   which delayed the FOUC-immune theme override in <head>. Fonts are now
   loaded from each admin HTML page's <head> via <link rel=preconnect>
   + <link rel=stylesheet> so the cascade starts immediately.
   ========================================================================== */

:root {
  --primary-color: #e11d48;
  --primary-hover: #be123c;
  --primary-light: #ffe4e6;
  --primary-rgb: 225, 29, 72;       /* Mirror of --primary-color for rgba() usage */
  --primary-hover-rgb: 190, 18, 60;
  --accent-color: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #dbeafe;
  --accent-rgb: 37, 99, 235;            /* Mirror of --accent-color for rgba() usage */
  --sidebar-bg: #090d16;
  --sidebar-hover: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --bg-admin: #f1f5f9;
  --card-admin: #ffffff;
  --border-admin: #e2e8f0;
  --text-dark: #0f172a;
  --text-muted: #64748b;
  --text-white: #ffffff;
  --success: #10b981;
  --success-rgb: 16, 185, 129;
  --warning: #f59e0b;
  --warning-rgb: 245, 158, 11;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-rgb: 239, 68, 68;
  --info: #3b82f6;
  --info-rgb: 59, 130, 246;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  overflow-x: hidden; /* strict — no horizontal scroll anywhere */
  max-width: 100vw;
}

body {
  font-family: 'Kanit', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans Lao", "Phetsarath",
               "Microsoft Sans Serif", "Microsoft JhengHei",
               "Apple SD Gothic Neo", sans-serif;
  background-color: var(--bg-admin);
  color: var(--text-dark);
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

/* ==========================================================================
   Sidebar Navigation
   ========================================================================== */
.admin-sidebar {
  width: 260px;
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.3s ease;
  border-right: 1px solid #1e293b;
  overflow: hidden;
}

/* Collapsed sidebar (desktop mini mode) */
.admin-sidebar.collapsed {
  width: 72px;
}
.admin-sidebar.collapsed .sidebar-brand-title,
.admin-sidebar.collapsed .sidebar-link span.link-text,
.admin-sidebar.collapsed .sidebar-link span.badge-count,
.admin-sidebar.collapsed .sidebar-footer .user-details,
.admin-sidebar.collapsed .sidebar-section-label {
  display: none;
}
.admin-sidebar.collapsed .sidebar-header {
  padding: 1.5rem 0.75rem;
  justify-content: center;
}
.admin-sidebar.collapsed .sidebar-link {
  padding: 0.75rem;
  justify-content: center;
}
.admin-sidebar.collapsed .sidebar-link .icon {
  margin: 0;
}
.admin-sidebar.collapsed .sidebar-footer {
  padding: 1rem 0.75rem;
  justify-content: center;
}

.sidebar-header {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid #1e293b;
  flex-shrink: 0;
}

.sidebar-header .logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}
.sidebar-header .logo-icon svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.6;
}

.sidebar-brand-title {
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s;
}

.sidebar-brand-title span {
  color: var(--primary-color);
}

/* Section label in sidebar */
.sidebar-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #334155;
  padding: 1.25rem 1rem 0.4rem;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-section-label:first-child {
  padding-top: 0.5rem;
}

.sidebar-nav {
  list-style: none;
  padding: 0.75rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex-grow: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #1e293b transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 2px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.93rem;
  transition: background 0.18s ease, color 0.18s ease, transform 0.15s ease;
  position: relative;
  white-space: nowrap;
}

.sidebar-link:hover {
  background-color: var(--sidebar-hover);
  color: var(--sidebar-text-active);
  transform: translateX(2px);
}

.sidebar-link.active {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(var(--primary-rgb), 0.35);
  font-weight: 600;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: rgba(255,255,255,0.5);
  border-radius: 0 2px 2px 0;
}

.sidebar-link .icon {
  font-size: 1.2rem;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Badge count on sidebar items */
.sidebar-link .badge-count {
  margin-left: auto;
  background: rgba(255,255,255,0.15);
  color: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 9999px;
  flex-shrink: 0;
}
.sidebar-link.active .badge-count {
  background: rgba(255,255,255,0.25);
}

/* Notification dot */
.sidebar-link .notif-dot {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 7px;
  height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--sidebar-bg);
  flex-shrink: 0;
}

/* Mini toggle button inside sidebar (desktop) */
.sidebar-collapse-btn {
  display: none;
  background: #1e293b;
  border: none;
  color: #94a3b8;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  margin-left: auto;
}
.sidebar-collapse-btn:hover {
  background: #334155;
  color: #fff;
}
.admin-sidebar.collapsed .sidebar-collapse-btn {
  transform: rotate(180deg);
}

.sidebar-link .icon svg, .sidebar-link svg {
  width: 1.25rem;
  height: 1.25rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.metric-icon svg {
  width: 26px;
  height: 26px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid #1e293b;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.admin-user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  /* Brand-aware gradient: blends the active Primary + Accent colors so
     the sidebar avatar always matches the theme set in Settings.
     Fallback colors mirror the default brand palette when theme is
     not yet applied. */
  background: linear-gradient(135deg, var(--primary-color, #e11d48) 0%, var(--accent-color, #2563eb) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.95rem;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow:
    0 1px 3px rgba(var(--primary-rgb, 225, 29, 72), 0.25),
    0 1px 2px rgba(var(--accent-rgb, 37, 99, 235), 0.20);
  letter-spacing: 0.02em;
  transition: box-shadow 0.2s ease;
}

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  gap: 0.1rem;
}

.user-name {
  color: #f1f5f9;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.user-role {
  color: #94a3b8;
  font-size: 0.72rem;
  white-space: nowrap;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.btn-logout {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 6px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */
.admin-main {
  margin-left: 260px;
  flex-grow: 1;
  min-width: 0; /* allow flex item to shrink below content size */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.admin-main.sidebar-collapsed {
  margin-left: 72px;
}

.admin-body {
  padding: 2rem;
  flex-grow: 1;
}

/* ==========================================================================
   Dashboard Metrics & Cards
   ========================================================================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--card-admin);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-admin);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.metric-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.icon-blue { background: #dbeafe; color: #2563eb; }
.icon-green { background: #d1fae5; color: #059669; }
.icon-orange { background: #fef3c7; color: #d97706; }
.icon-purple { background: #ede9fe; color: #7c3aed; }

.metric-info h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
}

.metric-info .number {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-top: 0.2rem;
}

/* ==========================================================================
   Content Card / Panels
   ========================================================================== */
.admin-card {
  background: var(--card-admin);
  border-radius: var(--radius);
  border: 1px solid var(--border-admin);
  min-width: 0; /* allow flex item to shrink */
  box-shadow: var(--shadow);
  padding: 1.75rem;
  margin-bottom: 2rem;
}

.card-header-bar {
  display: flex;
  justify-content: space-between;  /* Title LEFT, action RIGHT */
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-admin);
  flex-wrap: nowrap;
  gap: 1rem;
  max-width: 100%;
}

.card-header-bar > div:first-child {
  flex: 1 1 auto;  /* Title takes remaining space */
  min-width: 0;
}

.card-header-bar > div:last-child {
  flex-shrink: 0;
  min-width: 0;
  max-width: 100%;
}

/* On mobile, keep horizontal — never wrap below */
@media (max-width: 640px) {
  .card-header-bar {
    flex-wrap: nowrap;
  }
  .card-header-bar > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
  }
  .card-header-bar > div:last-child {
    flex-shrink: 0;
    min-width: auto;
  }
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.card-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ==========================================================================
   Data Tables
   ========================================================================== */
.table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  text-align: left;
  table-layout: auto;
}

.data-table td,
.data-table th {
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 280px;
  vertical-align: middle;
}

/* Strictly constrain the table to container — no expanding parent */
.data-table table,
.data-table {
  table-layout: fixed;
  width: 100%;
}

/* Action buttons: ALWAYS icon-only horizontal row, equal size, beautiful */
.btn-action-group {
  display: inline-flex;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.35rem;
  flex-wrap: nowrap;
}

/* Icon-only style: only when button contains an SVG */
.btn-action:has(svg) {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  padding: 0 !important;
  margin: 0 !important;
  font-size: 0 !important;
  line-height: 0 !important;
  border-radius: 50% !important;
  border: 1.5px solid transparent;
  background: #f1f5f9;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

/* Force SVG to be perfectly centered */
.btn-action svg {
  width: 16px !important;
  height: 16px !important;
  min-width: 16px;
  min-height: 16px;
  flex-shrink: 0;
  flex-grow: 0;
  display: block;
  margin: 0 auto;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Text-only button OR button with SVG + text: regular pill style */
.btn-action:not(:has(> svg:only-child)),
.btn-action:has(span) {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0.5rem 0.9rem !important;
  height: auto !important;
  min-width: auto !important;
  max-width: none !important;
  width: auto !important;
  font-size: 0.85rem !important;
  border-radius: 8px !important;
  font-weight: 500;
  gap: 0.35rem;
  line-height: 1;
}

/* btn-action-text: pill with icon + text, for card-header actions */
.btn-action-text {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem !important;
  height: auto !important;
  min-width: auto !important;
  max-width: none !important;
  width: auto !important;
  font-size: 0.85rem !important;
  font-weight: 600;
  border-radius: 8px !important;
  border: 1.5px solid transparent;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
  box-sizing: border-box;
  flex-shrink: 0;
}

.btn-action-text svg {
  width: 14px !important;
  height: 14px !important;
  flex-shrink: 0;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-action-text.primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
  color: #fff;
  border-color: var(--primary-hover);
  box-shadow: 0 2px 6px rgba(var(--primary-rgb), 0.25);
}
.btn-action-text.primary svg { stroke: #fff; }
.btn-action-text.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.35);
}

.btn-action-text.blue {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1e40af;
  border-color: #93c5fd;
}
.btn-action-text.blue svg { stroke: #1e40af; }
.btn-action-text.blue:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}
.btn-action-text.blue:hover svg { stroke: #fff; }

@media (max-width: 640px) {
  .btn-action-text {
    width: 100%;
    justify-content: center;
  }
}

/* Icon-only: button has SVG but NO text */
.btn-action:has(> svg:only-child) {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  padding: 0 !important;
  margin: 0 !important;
  font-size: 0 !important;
  line-height: 0 !important;
  border-radius: 50% !important;
}

/* Color variants per action */
.btn-action[title*="ดู"]:not(.delete),
.btn-action:not([title*="แก้ไข"]):not(.delete) {
  background: #dbeafe;
  color: #2563eb;
  border-color: #93c5fd;
}
.btn-action[title*="ดู"]:not(.delete) svg,
.btn-action:not([title*="แก้ไข"]):not(.delete) svg {
  stroke: #2563eb;
}
.btn-action[title*="ดู"]:not(.delete):hover,
.btn-action:not([title*="แก้ไข"]):not(.delete):hover {
  background: #2563eb;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}
.btn-action[title*="ดู"]:not(.delete):hover svg,
.btn-action:not([title*="แก้ไข"]):not(.delete):hover svg {
  stroke: #fff;
}

a.btn-action[href*="edit-car"] {
  background: #ede9fe;
  color: #7c3aed;
  border-color: #c4b5fd;
}
a.btn-action[href*="edit-car"] svg {
  stroke: #7c3aed;
}
a.btn-action[href*="edit-car"]:hover {
  background: #7c3aed;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(124, 58, 237, 0.3);
}
a.btn-action[href*="edit-car"]:hover svg {
  stroke: #fff;
}

/* Edit admin / generic purple edit button (matches edit-car styling) */
.btn-action.edit,
.btn-action[title^="แก้ไข"]:not(.delete):not([href*="edit-car"]) {
  background: #ede9fe;
  color: #7c3aed;
  border-color: #c4b5fd;
}
.btn-action.edit svg,
.btn-action[title^="แก้ไข"]:not(.delete):not([href*="edit-car"]) svg {
  stroke: #7c3aed;
}
.btn-action.edit:hover,
.btn-action[title^="แก้ไข"]:not(.delete):not([href*="edit-car"]):hover {
  background: #7c3aed;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(124, 58, 237, 0.3);
}
.btn-action.edit:hover svg,
.btn-action[title^="แก้ไข"]:not(.delete):not([href*="edit-car"]):hover svg {
  stroke: #fff;
}

.btn-action.delete {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}
.btn-action.delete svg {
  stroke: #dc2626;
}
.btn-action.delete:hover {
  background: #dc2626;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(220, 38, 38, 0.3);
}
.btn-action.delete:hover svg {
  stroke: #fff;
}

/* Always show all 8 columns horizontally — scroll if needed */
.table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.data-table.cars-table {
  /* Lock minimum width so all 8 columns fit */
  min-width: 920px;
  width: max-content; /* grow to fit content */
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
}

/* Tighter columns on desktop */
.data-table.cars-table .col-thumb { width: 90px; }
.data-table.cars-table .col-info { min-width: 200px; }
.data-table.cars-table .col-year { min-width: 130px; }
.data-table.cars-table .col-price { min-width: 120px; }
.data-table.cars-table .col-dealer { min-width: 130px; }
.data-table.cars-table .col-creator { min-width: 140px; }
.data-table.cars-table .col-status { min-width: 120px; }
.data-table.cars-table .col-actions { min-width: 150px; text-align: center; }

/* Header centered */
.data-table.cars-table th.col-actions {
  text-align: center !important;
}

/* Scrollbar styling + hint below table */
.table-responsive::-webkit-scrollbar { height: 8px; }
.table-responsive::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 4px; }
.table-responsive::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.table-responsive::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.table-responsive::after {
  content: '← เลื่อนดูข้อมูลทั้งหมด →';
  display: block;
  text-align: center;
  font-size: 0.72rem;
  color: #94a3b8;
  padding: 0.4rem;
  margin-top: 0.25rem;
}

/* On wide screens, no need to show scroll hint */
@media (min-width: 1100px) {
  .data-table.cars-table { min-width: 0; width: 100%; }
  .table-responsive::after { display: none; }
}

/* Dashboard recent cars table — more compact */
.dashboard-recent-table {
  min-width: 720px;
}
.dashboard-recent-table .col-thumb { width: 80px; }
.dashboard-recent-table .col-info { min-width: 220px; }
.dashboard-recent-table .col-year { min-width: 130px; }
.dashboard-recent-table .col-price { min-width: 110px; }
.dashboard-recent-table .col-status { min-width: 110px; }
.dashboard-recent-table .col-actions { min-width: 130px; text-align: center; }

@media (max-width: 900px) {
  .dashboard-recent-table { min-width: 640px; }
}

@media (min-width: 1100px) {
  .dashboard-recent-table { min-width: 0; width: 100%; }
}

/* Dealers table — 6 columns */
.dealers-table {
  min-width: 880px;
}
.dealers-table .col-info { min-width: 200px; }
.dealers-table .col-info-2 { min-width: 140px; }
.dealers-table .col-contact { min-width: 160px; }
.dealers-table .col-address { min-width: 200px; }
.dealers-table .col-stock { min-width: 110px; text-align: center; }
.dealers-table .col-actions { min-width: 130px; text-align: center; }

@media (max-width: 900px) {
  .dealers-table { min-width: 720px; }
}

@media (min-width: 1100px) {
  .dealers-table { min-width: 0; width: 100%; }
}

/* Logs table — 4 columns */
.logs-table {
  min-width: 680px;
}
.logs-table .col-time { min-width: 170px; }
.logs-table .col-action { min-width: 160px; }
.logs-table .col-detail { min-width: 240px; }
.logs-table .col-user { min-width: 160px; }

@media (max-width: 900px) {
  .logs-table { min-width: 560px; }
}

@media (min-width: 1100px) {
  .logs-table { min-width: 0; width: 100%; }
}

/* Admins table — 7 columns */
.admins-table {
  min-width: 880px;
}
.admins-table .col-num { width: 90px; text-align: center; white-space: nowrap; }
.admins-table .col-name { min-width: 240px; }
.admins-table .col-role { min-width: 130px; text-align: center; }
.admins-table .col-cars { min-width: 110px; text-align: center; }
.admins-table .col-activity { min-width: 160px; }
.admins-table .col-added { min-width: 140px; }
.admins-table .col-actions { min-width: 120px; text-align: center; }

@media (max-width: 900px) {
  .admins-table { min-width: 760px; }
}

@media (min-width: 1100px) {
  .admins-table { min-width: 0; width: 100%; }
}

/* Dashboard logs table — 4 columns */
.dashboard-logs-table {
  min-width: 600px;
}
.dashboard-logs-table .col-time { min-width: 160px; }
.dashboard-logs-table .col-action { min-width: 130px; }
.dashboard-logs-table .col-detail { min-width: 220px; }
.dashboard-logs-table .col-user { min-width: 140px; }

@media (max-width: 900px) {
  .dashboard-logs-table { min-width: 500px; }
}

@media (min-width: 1100px) {
  .dashboard-logs-table { min-width: 0; width: 100%; }
}

.data-table th {
  background: var(--bg-admin);
  padding: 0.85rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-admin);
  white-space: nowrap;
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, color 0.15s;
}
.data-table th.sortable:hover {
  background: #eef2ff;
  color: var(--primary-color);
}
.data-table th.sortable.active {
  color: var(--primary-color);
}
.sort-indicator {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.7rem;
  opacity: 0.4;
  transition: opacity 0.15s;
  vertical-align: middle;
}
.data-table th.sortable:hover .sort-indicator { opacity: 0.7; }
.data-table th.sortable.active .sort-indicator { opacity: 1; }

.data-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-admin);
  vertical-align: middle;
  font-size: 0.95rem;
}

.data-table tr:hover td {
  background-color: #f8fafc;
}

/* ===== Table toolbar + pagination (shared) ===== */
.table-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0;
  flex-wrap: wrap;
  min-height: 0;
  overflow: visible;
}
.table-settings-wrap {
  position: sticky;
  top: 64px;          /* pin below .admin-topbar (height 64px) */
  z-index: 80;
  align-self: flex-start;
  /* No card background / border / shadow — keep the floating button light */
}
.table-settings-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(203, 213, 225, 0.6);
  color: var(--text-muted);
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.table-settings-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: #fff;
  box-shadow: 0 2px 6px rgba(var(--primary-rgb), 0.12);
}
.table-settings-btn svg { width: 15px; height: 15px; opacity: 0.85; }

.table-settings-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border: 1px solid var(--border-admin);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  padding: 1rem;
  min-width: 240px;
  z-index: 50;
  display: none;
}
.table-settings-dropdown.open { display: block; }
.table-settings-dropdown h4 {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  font-weight: 600;
}
.table-settings-dropdown label.page-size-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-admin);
  margin-bottom: 0.85rem;
}
.table-settings-dropdown select.page-size-select {
  flex: 1;
  height: 32px;
  padding: 0 0.5rem;
  border: 1px solid var(--border-admin);
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fff;
}
.column-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 0.25rem;
}
.column-toggle-list label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.85rem;
  color: var(--text-admin);
  cursor: pointer;
  padding: 0.25rem 0.35rem;
  border-radius: 5px;
  transition: background 0.1s;
}
.column-toggle-list label:hover { background: #f1f5f9; }
.column-toggle-list input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary-color);
  cursor: pointer;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.pagination-info { white-space: nowrap; }
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}
.pagination-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 0.6rem;
  border: 1px solid var(--border-admin);
  background: #fff;
  color: var(--text-admin);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pagination-btn:hover:not(:disabled) {
  border-color: var(--primary-color);
  color: var(--primary-color);
}
.pagination-btn.active {
  background: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}
.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pagination-ellipsis {
  padding: 0 0.4rem;
  color: var(--text-muted);
  user-select: none;
}

.car-thumb-sm {
  width: 65px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-admin);
}

.car-cell {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.badge-status {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-available { background: #d1fae5; color: #065f46; }
.badge-reserved { background: #fef3c7; color: #92400e; }
.badge-sold { background: #f1f5f9; color: #475569; }

.status-select {
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border-admin);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-action-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-action {
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border-admin);
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.2s;
}

.btn-action.delete {
  color: var(--danger);
  border-color: #fecaca;
}

.btn-action.delete:hover {
  background: #fee2e2;
}

/* ==========================================================================
   Admin Form Controls
   ========================================================================== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-field.full-width {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dark);
}

.form-label span.req {
  color: var(--danger);
}

.input-admin {
  height: 44px;
  padding: 0.5rem 0.85rem;
  border: 1.5px solid var(--border-admin);
  border-radius: 8px;
  font-size: 0.95rem;
  background: #fff;
  transition: all 0.2s;
}

.input-admin:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea.input-admin {
  height: 120px;
  padding: 0.75rem;
  resize: vertical;
}

/* Image Upload Area */
.upload-dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-dropzone:hover {
  border-color: var(--primary-color);
  background: var(--primary-light);
}

.upload-icon {
  font-size: 2.5rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.upload-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
}

.preview-thumb-wrap {
  position: relative;
  width: 130px;
  height: 95px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border-admin);
  transition: all 0.2s ease;
  background: #0f172a;
}

.preview-thumb-wrap.is-cover {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.28);
}

.preview-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.badge-cover-tag {
  position: absolute;
  top: 4px;
  left: 4px;
  background: #f59e0b;
  color: #1e1b4b;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  gap: 3px;
  z-index: 2;
}

.btn-set-cover-action {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.85);
  color: #f8fafc;
  border: none;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 4px 0;
  text-align: center;
  cursor: pointer;
  backdrop-filter: blur(2px);
  transition: all 0.2s ease;
  z-index: 2;
}

.btn-set-cover-action:hover {
  background: #f59e0b;
  color: #0f172a;
  font-weight: 700;
}

.btn-remove-thumb {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  transition: background 0.2s;
}

.btn-remove-thumb:hover {
  background: rgba(220, 38, 38, 1);
  transform: scale(1.1);
}

.btn-submit-car {
  padding: 0.75rem 2rem;
  background: var(--primary-color);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.25);
  transition: all 0.2s;
}

.btn-submit-car:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

/* Color Picker Row */
.color-picker-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.color-input-box {
  width: 50px;
  height: 44px;
  padding: 2px;
  border: 1.5px solid var(--border-admin);
  border-radius: 8px;
  cursor: pointer;
  background: #fff;
}

/* Toast Notification */
.toast-notice {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #fff;
  padding: 0.85rem 1.25rem;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 9999;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 3px solid var(--primary-color);
}

.toast-notice.show {
  transform: translateY(0);
  opacity: 1;
}

/* ==========================================================================
   Slide Editor (Banner Slideshow) — Card-based Layout
   ========================================================================== */
.slide-editor-wrap {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1.5px solid var(--border-admin);
  border-radius: 14px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.slide-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.slide-interval-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: var(--text-dark);
  font-weight: 500;
  background: #fff;
  padding: 0.5rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border-admin);
}

.slide-interval-row input {
  width: 64px;
  height: 32px;
  padding: 0.2rem 0.5rem;
  border: 1.5px solid var(--border-admin);
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  background: #f8fafc;
  color: var(--primary-color);
}

.slide-interval-row input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: #fff;
}

.slide-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 600px;
  overflow-y: auto;
  padding: 0.25rem;
  margin: -0.25rem;
}

.slide-list::-webkit-scrollbar { width: 6px; }
.slide-list::-webkit-scrollbar-track { background: transparent; }
.slide-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.slide-list::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── Each slide row ─── */
.slide-editor-row {
  background: #fff;
  border: 1px solid var(--border-admin);
  border-radius: 14px;
  overflow: hidden;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.slide-editor-row:hover {
  border-color: #cbd5e1;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

/* Header bar: badge + status + actions */
.slide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  border-bottom: 1px solid var(--border-admin);
}

.slide-header-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.slide-num-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.75rem;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 999px;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 4px rgba(var(--primary-rgb), 0.25);
}

.slide-status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}

.slide-status svg {
  width: 12px;
  height: 12px;
}

.slide-status.ready {
  background: #d1fae5;
  color: #047857;
}

.slide-status.incomplete {
  background: #fef3c7;
  color: #92400e;
}

.slide-header-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.slide-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border-admin);
  background: #fff;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.slide-btn-icon:hover:not(:disabled) {
  background: var(--bg-admin);
  color: var(--text-dark);
  transform: translateY(-1px);
}

.slide-btn-icon:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.slide-btn-icon svg {
  width: 14px;
  height: 14px;
}

.slide-btn-icon-danger:hover:not(:disabled) {
  background: #fee2e2;
  border-color: #fecaca;
  color: var(--danger);
}

/* ─── Two image cards side-by-side ─── */
.slide-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  padding: 1rem;
  align-items: stretch;
}

.slide-card {
  border: 1.5px solid var(--border-admin);
  border-radius: 12px;
  padding: 0.75rem;
  background: #fafbfc;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  /* Equal sizing: ensure input row sits at the bottom in both cards */
  min-width: 0;
}

.slide-card-desktop {
  border-top: 3px solid var(--primary-color, #e11d48);
}

.slide-card-mobile {
  border-top: 3px solid var(--accent-color, #2563eb);
}

.slide-card.has-image {
  background: #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
}

.slide-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.slide-card-title {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dark);
}

.slide-card-desktop .slide-card-title { color: var(--primary-color, #e11d48); }
.slide-card-mobile .slide-card-title { color: var(--accent-color, #2563eb); }

.slide-card-title svg {
  width: 14px;
  height: 14px;
}

.slide-card-size {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  background: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border-admin);
}

.slide-card-preview-wrap {
  position: relative;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: #f1f5f9;
  border: 1px dashed var(--border-admin);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Desktop: 1920×650 ≈ 2.95:1 (wide banner) */
  aspect-ratio: 1920 / 650;
}

.slide-card-preview-wrap-mobile {
  /* Mobile: 1920×650 (same ratio as desktop, unified banner) */
  aspect-ratio: 1920 / 650;
  max-height: 220px;
  width: auto;
  margin-left: auto;
  margin-right: auto;
  margin-top: auto;
  margin-bottom: auto;
}

.slide-card-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.slide-card-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  color: #94a3b8;
  font-size: 0.72rem;
  width: 100%;
  height: 100%;
}

.slide-card-empty svg {
  width: 28px;
  height: 28px;
}

.slide-card-input-row {
  display: grid;
  grid-template-columns: 1fr 88px;
  align-items: stretch;
  gap: 0.4rem;
  /* Always push to bottom of card */
  margin-top: auto;
  padding-top: 0.25rem;
}

.slide-card-input-row .slide-url-input {
  width: 100%;
  height: 36px;
  font-size: 0.78rem;
  padding: 0.3rem 0.6rem;
  border: 1.5px solid var(--border-admin);
  border-radius: 8px;
  background: #fff;
  min-width: 0;
}

.slide-card-input-row .slide-url-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.slide-card-input-row .slide-url-input::placeholder {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.slide-upload-btn {
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--border-admin);
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: all 0.2s;
  flex-shrink: 0;
}

.slide-upload-btn:hover {
  border-color: var(--primary-color);
  background: var(--primary-light);
  color: var(--primary-color);
}

.slide-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border-admin);
  background: #fff;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: all 0.2s;
  flex-shrink: 0;
}

.slide-btn:hover:not(:disabled) {
  background: var(--bg-admin);
  color: var(--text-dark);
  transform: translateY(-1px);
}

.slide-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.slide-btn-delete:hover:not(:disabled) {
  background: #fee2e2;
  border-color: #fecaca;
  color: var(--danger);
}

.slide-btn-move:hover:not(:disabled) {
  background: var(--accent-light);
  border-color: #bfdbfe;
  color: var(--accent-color);
}

.slide-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.slide-empty-msg {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  background: #fff;
  border: 1px dashed var(--border-admin);
  border-radius: 10px;
}

/* ─── Dual Image Fields (Desktop + Mobile) ─── */
.slide-row-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  flex-wrap: wrap;
  justify-content: space-between;
}

.slide-num-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 0.6rem;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 14px;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 4px rgba(var(--primary-rgb), 0.25);
}

.slide-num-badge::before {
  content: 'สไลด์ ';
  font-size: 0.65rem;
  font-weight: 500;
  opacity: 0.85;
  margin-right: 2px;
}

.slide-image-fields {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1;
  min-width: 0;
}

.slide-image-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f8fafc;
  padding: 0.45rem 0.55rem;
  border-radius: 10px;
  border: 1.5px solid transparent;
  transition: all 0.2s;
  position: relative;
}

.slide-image-field-desktop {
  border-left: 3px solid #2563eb;
}

.slide-image-field-mobile {
  border-left: 3px solid #db2777;
}

.slide-image-field:focus-within {
  border-color: var(--primary-color);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-light);
}

.slide-image-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 78px;
  justify-content: center;
}

.slide-image-label-desktop {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1e40af;
}

.slide-image-label-mobile {
  background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
  color: #9d174d;
}

.slide-image-field .slide-url-input {
  height: 34px;
  font-size: 0.78rem;
  background: #fff;
  border: 1px solid var(--border-admin);
  flex: 1;
  min-width: 0;
}

.slide-card-input-row .btn-upload-file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  width: 100%;
  height: 36px;
  padding: 0;
  border: 1.5px solid var(--border-admin);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
}

.slide-card-input-row .btn-upload-file svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.slide-card-input-row .btn-upload-file::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.6) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.6s;
}

.slide-card-input-row .btn-upload-file:hover::before {
  transform: translateX(100%);
}

.slide-card-desktop .btn-upload-file:hover {
  border-color: var(--primary-color, #e11d48);
  background: linear-gradient(135deg, var(--primary-light, #ffe4e6) 0%, var(--primary-light, #ffe4e6) 100%);
  color: var(--primary-hover, #be123c);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(var(--primary-rgb, 225, 29, 72), 0.25);
}

.slide-card-mobile .btn-upload-file:hover {
  border-color: var(--accent-color, #2563eb);
  background: linear-gradient(135deg, var(--accent-light, #dbeafe) 0%, var(--accent-light, #dbeafe) 100%);
  color: var(--accent-hover, #1d4ed8);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(var(--accent-rgb, 37, 99, 235), 0.25);
}

/* Uploading state */
.slide-card-input-row .btn-upload-file.uploading {
  pointer-events: none;
  background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
  border-color: #6366f1;
  color: #4338ca;
}

.slide-card-input-row .btn-upload-file.uploading span,
.slide-card-input-row .btn-upload-file.uploading svg {
  opacity: 0;
}

.slide-card-input-row .btn-upload-file.uploading::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid #6366f1;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Add slide button — gradient style */
.btn-add-slide {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1.1rem;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.25);
  transition: all 0.2s;
}

.btn-add-slide:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(var(--primary-rgb), 0.35);
}

.btn-add-slide:active {
  transform: translateY(0);
}

.btn-add-slide svg {
  width: 16px;
  height: 16px;
  stroke: #fff;
}

/* ============================================================
   Add Car (primary CTA on /admin/cars.html)
   - Distinct from utility/filter buttons (filled gradient vs outline)
   - Sits in its own row above the filter toolbar so the user
     immediately sees the MAIN action on this page.
   ============================================================ */
.cars-header-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.65rem;
  flex: 1;
  min-width: 0;
}

.cars-header-cta-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.cars-header-filter-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}

.btn-add-car {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(var(--primary-rgb, 225, 29, 72), 0.28);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  flex-shrink: 0;
  /* Match outline of .btn-add-slide so the visual language is consistent */
}

.btn-add-car:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(var(--primary-rgb, 225, 29, 72), 0.38);
  filter: brightness(1.05);
  color: #ffffff;
}

.btn-add-car:active {
  transform: translateY(0);
  box-shadow: 0 3px 8px rgba(var(--primary-rgb, 225, 29, 72), 0.28);
}

.btn-add-car:focus-visible {
  outline: 2px solid var(--primary-color, #e11d48);
  outline-offset: 2px;
  color: #ffffff;
}

.btn-add-car-icon {
  width: 18px;
  height: 18px;
  stroke: #ffffff;
  stroke-width: 2.5;
  flex-shrink: 0;
}

.btn-add-car > span {
  line-height: 1;
}

/* Tablet: keep button as text + icon */
@media (max-width: 1024px) {
  .btn-add-car {
    padding: 0.55rem 1rem;
    font-size: 0.85rem;
  }
  .btn-add-car-icon { width: 16px; height: 16px; }
}

/* Mobile: CTA collapses to icon-only square (matches .btn-visit-site / .btn-action pattern) */
@media (max-width: 768px) {
  .cars-header-cta-row { justify-content: stretch; }
  .btn-add-car {
    width: 100%;
    padding: 0.55rem 0.75rem;
    justify-content: center;
  }
  .btn-add-car > span { font-size: 0.85rem; }
}

@media (max-width: 480px) {
  .btn-add-car {
    padding: 0.5rem 0.6rem;
  }
  .btn-add-car > span { font-size: 0.8rem; }
  .btn-add-car-icon { width: 15px; height: 15px; }
}

/* Mobile-friendly slide editor */
@media (max-width: 768px) {
  .slide-cards {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding: 0.75rem;
  }

  .slide-card-preview-wrap,
  .slide-card-preview-wrap-mobile {
    height: 140px;
  }

  .slide-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .slide-card-input-row {
    flex-wrap: wrap;
  }

  .slide-card-input-row .slide-url-input {
    width: 100%;
    order: 1;
  }

  .slide-card-input-row .btn-upload-file {
    width: 100%;
    justify-content: center;
    order: 2;
  }
}

/* ==========================================================================
   Topbar — Mobile Header
   ========================================================================== */
.admin-topbar {
  background: var(--card-admin);
  height: 64px;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--border-admin);
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  min-width: 0;
}

.topbar-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Hamburger / sidebar toggle — mobile only */
.admin-sidebar-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-dark);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}
.admin-sidebar-toggle:hover { background: var(--bg-admin); }
.admin-sidebar-toggle:active { background: #e2e8f0; transform: scale(0.95); }
.admin-sidebar-toggle svg { width: 22px; height: 22px; stroke: currentColor; fill: none; }

/* Notification bell button */
.topbar-notif-btn {
  position: relative;
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}
.topbar-notif-btn:hover { background: var(--bg-admin); color: var(--text-dark); }
.topbar-notif-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; }
.topbar-notif-btn .notif-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid #fff;
}

/* Visit site button */
.btn-visit-site {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  background: var(--bg-admin);
  color: var(--text-dark);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid var(--border-admin);
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-visit-site:hover { background: #e2e8f0; }

/* Backdrop */
.admin-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(3px);
  z-index: 95;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.admin-sidebar-backdrop.show {
  display: block;
  opacity: 1;
}

/* ==========================================================================
   Daily Car Additions — Statistics Card
   --------------------------------------------------------------------------
   Compact stat card placed above the cars table. Lets admin pick a date
   range (from-to) and see how many cars were added per day, plus an
   inline bar chart (CSS-only) so peak days jump out without a chart lib.
   ========================================================================== */
.daily-stat-card {
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
}
.daily-stat-card .card-header-bar {
  margin-bottom: 1rem;
}
.daily-stat-filters {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 0.85rem 1rem;
  background: #f8fafc;
  border: 1px solid var(--border-admin);
  border-radius: 10px;
  margin-bottom: 1rem;
}
.daily-stat-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 150px;
}
.daily-stat-field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.daily-stat-field input[type="date"] {
  height: 38px;
  padding: 0 0.7rem;
  border: 1.5px solid var(--border-admin);
  border-radius: 8px;
  font-size: 0.88rem;
  background: #fff;
  color: var(--text-dark);
  font-family: inherit;
  transition: all 0.2s;
}
.daily-stat-field input[type="date"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.daily-stat-presets {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}
.daily-stat-preset-btn {
  height: 38px;
  padding: 0 0.85rem;
  border: 1.5px solid var(--border-admin);
  border-radius: 8px;
  background: #fff;
  color: var(--text-dark);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.daily-stat-preset-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: var(--primary-light);
}
.daily-stat-preset-btn.active {
  background: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}
.daily-stat-clear-btn {
  height: 38px;
  padding: 0 0.85rem;
  border: 1.5px solid #fecaca;
  border-radius: 8px;
  background: #fff;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.daily-stat-clear-btn:hover {
  background: #fef2f2;
  border-color: var(--danger);
}
.daily-stat-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.daily-stat-tile {
  padding: 0.85rem 1rem;
  background: #fff;
  border: 1px solid var(--border-admin);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  position: relative;
  overflow: hidden;
}
.daily-stat-tile::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary-color);
}
.daily-stat-tile.tile-accent::before { background: var(--accent-color); }
.daily-stat-tile.tile-success::before { background: var(--success); }
.daily-stat-tile.tile-warning::before { background: var(--warning); }
.daily-stat-tile-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.daily-stat-tile-label svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.daily-stat-tile-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.daily-stat-tile-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}
.daily-stat-chart {
  background: #fff;
  border: 1px solid var(--border-admin);
  border-radius: 10px;
  padding: 1rem 1rem 0.75rem;
  margin-bottom: 1rem;
}
.daily-stat-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.daily-stat-chart-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.daily-stat-chart-title svg {
  width: 18px;
  height: 18px;
  stroke: var(--primary-color);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.daily-stat-chart-legend {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.daily-stat-chart-legend .legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 0.3rem;
  vertical-align: middle;
}
.daily-stat-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 160px;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-admin);
  overflow-x: auto;
  scrollbar-width: thin;
}
.daily-stat-bars::-webkit-scrollbar { height: 6px; }
.daily-stat-bars::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.daily-stat-bar-col {
  flex: 1 0 auto;
  min-width: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  height: 100%;
  position: relative;
  cursor: pointer;
}
.daily-stat-bar-count {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1;
}
.daily-stat-bar {
  width: 100%;
  background: linear-gradient(180deg, var(--primary-color) 0%, var(--primary-hover) 100%);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: opacity 0.15s, transform 0.15s;
  position: relative;
}
.daily-stat-bar-col:hover .daily-stat-bar {
  opacity: 0.85;
  transform: translateY(-2px);
}
.daily-stat-bar-col:hover .daily-stat-bar-tip {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -4px);
}
.daily-stat-bar-tip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translate(-50%, 0);
  background: #0f172a;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.15s ease;
  z-index: 5;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.daily-stat-bar-tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #0f172a;
}
.daily-stat-bar-day {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.35rem;
  white-space: nowrap;
}
.daily-stat-bar-day.today { color: var(--primary-color); font-weight: 700; }
.daily-stat-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}
.daily-stat-empty svg {
  width: 40px;
  height: 40px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  opacity: 0.5;
  margin-bottom: 0.5rem;
}
.daily-stat-list {
  background: #fff;
  border: 1px solid var(--border-admin);
  border-radius: 10px;
  max-height: 320px;
  overflow-y: auto;
}
.daily-stat-list-head,
.daily-stat-list-row {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 1.6fr 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
}
.daily-stat-list-head {
  position: sticky;
  top: 0;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-admin);
  font-weight: 700;
  color: var(--text-dark);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  z-index: 2;
}
.daily-stat-list-row {
  border-bottom: 1px solid #f1f5f9;
}
.daily-stat-list-row:last-child { border-bottom: none; }
.daily-stat-list-row:hover { background: #f8fafc; }
.daily-stat-list-row .row-bar {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-hover) 100%);
  max-width: 100%;
  min-width: 4px;
}
.daily-stat-list-row .row-count {
  font-weight: 700;
  color: var(--primary-color);
}
.daily-stat-list-row .row-date {
  font-weight: 600;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.daily-stat-list-row .row-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  background: var(--primary-light);
  color: var(--primary-color);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
}
.daily-stat-list-row .row-weekday {
  color: var(--text-muted);
  font-size: 0.78rem;
}
.daily-stat-list-row.is-today {
  background: linear-gradient(90deg, rgba(var(--primary-rgb), 0.08) 0%, transparent 100%);
}
.daily-stat-list-row.is-today .row-date { color: var(--primary-color); }
.daily-stat-view-toggle {
  display: inline-flex;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.daily-stat-view-toggle button {
  border: none;
  background: transparent;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.daily-stat-view-toggle button svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
.daily-stat-view-toggle button.active {
  background: #fff;
  color: var(--primary-color);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Daily stat card mobile tweaks */
@media (max-width: 768px) {
  .daily-stat-filters {
    flex-direction: column;
    align-items: stretch;
  }
  .daily-stat-field, .daily-stat-presets {
    width: 100%;
  }
  .daily-stat-preset-btn, .daily-stat-clear-btn { flex: 1; }
  .daily-stat-summary { grid-template-columns: repeat(2, 1fr); }
  .daily-stat-tile-value { font-size: 1.25rem; }
  .daily-stat-list-head,
  .daily-stat-list-row {
    grid-template-columns: 1fr 0.5fr 1fr 0.5fr;
    font-size: 0.78rem;
    gap: 0.5rem;
  }
  .daily-stat-header-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .daily-stat-toggle-btn { width: 100%; justify-content: center; }
}

/* Collapsible detail (กราฟ + ตาราง) container */
.daily-stat-detail {
  display: block;
  animation: dailyDetailIn 0.25s ease;
}
.daily-stat-detail[hidden] { display: none !important; }
@keyframes dailyDetailIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Right side of card-header: toggle button + view-mode tabs */
.daily-stat-header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.daily-stat-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  background: #fff;
  border: 1.5px solid var(--border-admin);
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-family: inherit;
}
.daily-stat-toggle-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: var(--primary-light);
}
.daily-stat-toggle-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  transition: transform 0.2s ease;
}
.daily-stat-toggle-btn[aria-expanded="true"] svg {
  transform: rotate(180deg);
}
.daily-stat-toggle-btn[aria-expanded="true"] {
  background: var(--primary-light);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

/* Large desktops / wide laptops  (≤1280px) */
@media (max-width: 1280px) {
  .admin-body { padding: 1.75rem; }
  .admin-card  { padding: 1.5rem; }
}

/* Tablets landscape / small laptops / iPad landscape (≤1024px) */
@media (max-width: 1024px) {
  .admin-sidebar     { width: 220px; }
  .admin-main        { margin-left: 220px; }
  .admin-main.sidebar-collapsed { margin-left: 220px; }
  .admin-sidebar.collapsed      { width: 220px; }
  .admin-sidebar.collapsed .sidebar-brand-title,
  .admin-sidebar.collapsed .sidebar-link span.link-text,
  .admin-sidebar.collapsed .sidebar-link span.badge-count,
  .admin-sidebar.collapsed .sidebar-footer .user-details,
  .admin-sidebar.collapsed .sidebar-section-label { display: initial; }
  .admin-sidebar.collapsed .sidebar-header { padding: 1.5rem; justify-content: flex-start; }
  .admin-sidebar.collapsed .sidebar-link { padding: 0.7rem 1rem; justify-content: flex-start; }
  .admin-sidebar.collapsed .sidebar-footer { padding: 1rem 1.25rem; justify-content: space-between; }
  .sidebar-collapse-btn { display: flex; }
  .admin-body          { padding: 1.5rem; }
  .metrics-grid        { grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
  .form-grid           { gap: 1.25rem; }
}

/* Tablets portrait / iPad portrait  (≤900px) — off-canvas sidebar */
@media (max-width: 900px) {
  body { display: block; }

  .admin-sidebar {
    transform: translateX(-100%);
    box-shadow: none;
    width: 268px;
    z-index: 200;
  }
  .admin-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 40px rgba(0, 0, 0, 0.4);
  }

  .admin-main {
    margin-left: 0;
    width: 100%;
    min-height: 100vh;
  }
  .admin-main.sidebar-collapsed { margin-left: 0; }

  /* Show hamburger in topbar */
  .admin-sidebar-toggle { display: inline-flex; }

  /* Always show expand button on mobile for clarity */
  .sidebar-collapse-btn { display: none !important; }

  .admin-topbar {
    padding: 0 1.25rem;
    height: 60px;
  }
  .topbar-title { font-size: 1.05rem; line-height: 1.3; }
  .topbar-right { gap: 0.5rem; }

  .admin-body       { padding: 1.25rem 1rem; }
  .metrics-grid      { grid-template-columns: 1fr 1fr; gap: 1rem; }
  .metric-card       { padding: 1.1rem; gap: 1rem; }
  .metric-icon       { width: 44px; height: 44px; font-size: 1.25rem; }
  .metric-info .number { font-size: 1.45rem; }
  .admin-card        { padding: 1.25rem; margin-bottom: 1.5rem; }
  .card-title        { font-size: 1.1rem; }
  .form-grid         { grid-template-columns: 1fr 1fr; gap: 1rem; }
  .form-field.full-width { grid-column: 1 / -1; }
}

/* Large phones  (≤768px) */
@media (max-width: 768px) {
  .admin-topbar { padding: 0 1rem; height: 58px; }
  .table-settings-wrap { top: 58px; }
  .topbar-title {
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
  }
  .btn-visit-site span { display: none; }
  .btn-action span { display: none; }
  .btn-visit-site { padding: 0.5rem 0.6rem; }
  .btn-action     { padding: 0.5rem 0.6rem; }
  .btn-submit-car { padding: 0.6rem 0.9rem; font-size: 0.9rem; }
  .btn-visit-site svg { width: 1.2rem; height: 1.2rem; }

  .admin-body      { padding: 1rem 0.85rem; }
  .metrics-grid     { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  .metric-card      { padding: 0.9rem; gap: 0.85rem; }
  .metric-icon      { width: 40px; height: 40px; }
  .metric-info h4  { font-size: 0.72rem; }
  .metric-info .number { font-size: 1.25rem; }
  .admin-card      { padding: 1rem; margin-bottom: 1.25rem; border-radius: 10px; }
  .card-header-bar {
    flex-direction: column; align-items: flex-start;
    gap: 0.85rem; margin-bottom: 1rem; padding-bottom: 0.85rem;
  }
  .card-title      { font-size: 1rem; }
  .card-subtitle   { font-size: 0.8rem; }
  .form-grid       { grid-template-columns: 1fr; gap: 1rem; }
  .input-admin     { font-size: 0.92rem; height: 42px; }
  textarea.input-admin { height: 110px; }
  .upload-dropzone { padding: 1.25rem 1rem; }
  .upload-previews { gap: 0.65rem; }
  .preview-thumb-wrap { width: 100px; height: 75px; }
  .data-table th, .data-table td { padding: 0.65rem 0.6rem; font-size: 0.85rem; }
  .data-table th  { font-size: 0.72rem; }
}

/* Small phones  (≤640px) */
@media (max-width: 640px) {
  .admin-topbar { padding: 0 0.75rem; height: 56px; }
  .admin-sidebar-toggle { width: 36px; height: 36px; }
  .admin-sidebar-toggle svg { width: 20px; height: 20px; }
  .topbar-title { font-size: 0.95rem; }
  .admin-body   { padding: 0.85rem 0.75rem; }
  .metrics-grid { grid-template-columns: 1fr 1fr; gap: 0.65rem; }
  .metric-card  { padding: 0.85rem; flex-direction: column; align-items: flex-start; gap: 0.6rem; }
  .metric-icon  { width: 36px; height: 36px; font-size: 1rem; }
  .metric-info h4    { font-size: 0.68rem; }
  .metric-info .number { font-size: 1.1rem; }
  .admin-card   { padding: 0.9rem; border-radius: 8px; }
  .card-title  { font-size: 0.95rem; }
  .btn-action-group { flex-wrap: wrap; gap: 0.35rem; }
  .btn-action  { padding: 0.3rem 0.5rem; font-size: 0.78rem; }
  .upload-dropzone { padding: 1rem 0.75rem; }
  .upload-icon { font-size: 1.85rem; }
  .data-table th, .data-table td { padding: 0.55rem 0.45rem; font-size: 0.8rem; }
  .data-table th { font-size: 0.68rem; }
}

/* Extra small phones  (≤480px) */
@media (max-width: 480px) {
  .admin-topbar   { padding: 0 0.65rem; }
  .topbar-title   { font-size: 0.9rem; }
  .btn-visit-site { padding: 0.4rem 0.5rem; }
  .admin-sidebar  { width: 248px; }
  .admin-body     { padding: 0.75rem 0.6rem; }
  .metric-card    { padding: 0.75rem; }
  .admin-card     { padding: 0.85rem; }
}

/* ==========================================================================
   Accessibility & Utilities
   ========================================================================== */
body.sidebar-open { overflow: hidden; }

@media (min-width: 901px) {
  .admin-sidebar-backdrop { display: none !important; }
  .admin-sidebar-toggle   { display: none !important; }
}

/* Focus styles for keyboard nav */
.sidebar-link:focus-visible,
.admin-sidebar-toggle:focus-visible,
.btn-logout:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Smooth scroll */
.admin-body { scroll-behavior: smooth; }

/* ==========================================================================
   Admin Shell — Refined Sidebar & Topbar
   Styles for the unified admin-shell.js layout
   ========================================================================== */

/* ─── Brand area ─────────────────────────────────────────────────── */
.sidebar-header {
  position: relative;
}
.sidebar-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 1rem;
  right: 1rem;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(var(--primary-rgb), 0.4), transparent);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}
.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  overflow: hidden;
}
.brand-title {
  color: #fff;
  font-size: 1.18rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-title span {
  color: var(--primary-color);
}
.brand-subtitle {
  color: #64748b;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Sections & labels ──────────────────────────────────────────── */
.sidebar-section {
  padding: 0.25rem 0.6rem;
}
.sidebar-section-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
}
.sidebar-section-label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 1rem 0.4rem 0.45rem;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-section-dot {
  width: 5px;
  height: 5px;
  background: var(--primary-color);
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(var(--primary-rgb), 0.6);
}
.sidebar-section-label .label-text {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: #94a3b8;
}

/* ─── Sidebar link (refined) ──────────────────────────────────────── */
.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px;
  height: 60%;
  background: linear-gradient(to bottom, var(--primary-color), var(--primary-hover));
  border-radius: 0 3px 3px 0;
  transition: transform 0.25s ease;
}
.sidebar-link:hover {
  background-color: rgba(30, 41, 59, 0.85);
  color: var(--sidebar-text-active);
  transform: translateX(3px);
}
.sidebar-link:hover::before {
  transform: translateY(-50%) scaleY(0.6);
  background: var(--primary-color);
}
.sidebar-link.active {
  background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.95), rgba(var(--primary-hover-rgb), 0.95));
  color: #ffffff;
  box-shadow:
    0 6px 18px rgba(var(--primary-rgb), 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  font-weight: 600;
}
.sidebar-link.active::before {
  transform: translateY(-50%) scaleY(1);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}
.sidebar-link-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: currentColor;
}
.sidebar-link-icon svg {
  width: 1.15rem;
  height: 1.15rem;
  stroke: currentColor;
}
.sidebar-link-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-link-indicator {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.7);
  flex-shrink: 0;
}

/* Legacy compatibility — keep old selectors working where pages still use them */
.sidebar-link .icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: currentColor;
}
.sidebar-link .icon svg,
.sidebar-link svg {
  width: 1.15rem;
  height: 1.15rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sidebar-link span.link-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-link .badge-count {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.15);
  color: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 9999px;
  flex-shrink: 0;
}
.sidebar-link.active .badge-count {
  background: rgba(255, 255, 255, 0.25);
}

/* ─── Sidebar user footer ────────────────────────────────────────── */
.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 0.85rem 1.15rem 0.85rem 1.15rem;
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  padding: 0.25rem 0.15rem;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.sidebar-user .user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  overflow: hidden;
  min-width: 0;
  gap: 0.18rem;
}

/* ─── Topbar (refined) ───────────────────────────────────────────── */
.admin-topbar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 90;
}
.topbar-title-wrap {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  flex: 1;
  min-width: 0;
  margin-left: 0.25rem;
}
.topbar-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  letter-spacing: -0.01em;
}
.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-breadcrumb-icon {
  width: 12px !important;
  height: 12px !important;
  opacity: 0.55;
  flex-shrink: 0;
  vertical-align: middle;
}
.topbar-breadcrumb-sep {
  display: inline-flex;
  align-items: center;
  opacity: 0.65;
}
.topbar-breadcrumb-current {
  color: var(--text-dark);
  font-weight: 600;
}

/* ─── Sidebar collapsed (desktop mini mode) ──────────────────────── */
.admin-sidebar.collapsed {
  width: 76px;
}
.admin-sidebar.collapsed .sidebar-brand-text,
.admin-sidebar.collapsed .sidebar-section-label .label-text,
.admin-sidebar.collapsed .sidebar-link-text,
.admin-sidebar.collapsed .sidebar-link-indicator,
.admin-sidebar.collapsed .sidebar-user .user-info {
  display: none;
}
.admin-sidebar.collapsed .sidebar-header {
  padding: 1.4rem 0.5rem;
  justify-content: center;
}
.admin-sidebar.collapsed .sidebar-brand {
  justify-content: center;
}
.admin-sidebar.collapsed .sidebar-collapse-btn {
  position: absolute;
  top: 1rem;
  right: 0.5rem;
  margin-left: 0;
}
.admin-sidebar.collapsed .sidebar-section {
  padding: 0.25rem 0.4rem;
}
.admin-sidebar.collapsed .sidebar-section-label {
  padding: 0.9rem 0 0.3rem;
  justify-content: center;
}
.admin-sidebar.collapsed .sidebar-section-dot {
  margin: 0 auto;
}
.admin-sidebar.collapsed .sidebar-link {
  justify-content: center;
  padding: 0.7rem;
}
.admin-sidebar.collapsed .sidebar-link-icon {
  margin: 0;
}
.admin-sidebar.collapsed .sidebar-footer {
  padding: 0.85rem 0.5rem;
  justify-content: center;
}
.admin-sidebar.collapsed .sidebar-user {
  justify-content: center;
}
.admin-sidebar.collapsed .user-avatar {
  width: 38px;
  height: 38px;
}
.admin-sidebar.collapsed .btn-logout {
  display: none;
}

/* Tooltip for collapsed sidebar links */
.admin-sidebar.collapsed .sidebar-link {
  position: relative;
}
.admin-sidebar.collapsed .sidebar-link::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(-6px);
  background: #0f172a;
  color: #fff;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 200;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  border: 1px solid #1e293b;
}
.admin-sidebar.collapsed .sidebar-link::before {
  /* Hide active marker in collapsed to avoid clutter */
  display: none;
}
.admin-sidebar.collapsed .sidebar-link:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* ─── Responsive tweaks for shell ────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar-collapse-btn { display: none !important; }
}

@media (max-width: 768px) {
  .topbar-breadcrumb { display: none; }
  .topbar-title { font-size: 1.05rem; }
}

@media (max-width: 480px) {
  .topbar-title-wrap { margin-left: 0; }
  .topbar-title { font-size: 0.95rem; }
}

/* ============================================================
   Duplicate detection (cars page)
   ============================================================ */
.dup-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 38px;
  padding: 0 0.85rem;
  background: #fff;
  color: #b45309;
  border: 1.5px solid #fbbf24;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  position: relative;
}
.dup-toggle-btn:hover {
  background: #fef3c7;
  border-color: #f59e0b;
}
.dup-toggle-btn.active {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #fff;
  border-color: #d97706;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.25);
}
.dup-toggle-btn .dup-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  background: #fbbf24;
  color: #78350f;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  margin-left: 0.15rem;
}
.dup-toggle-btn.active .dup-count {
  background: rgba(255, 255, 255, 0.28);
  color: #fff;
}
.dup-toggle-btn .dup-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.badge-dup {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.4rem;
  padding: 0.12rem 0.5rem;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
  border: 1px solid #f59e0b;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  vertical-align: middle;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.badge-dup:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.35);
}
.badge-dup svg {
  width: 11px;
  height: 11px;
  stroke: #b45309;
  stroke-width: 2.5;
  flex-shrink: 0;
}

tr.row-dup {
  background: #fffbeb !important;
}
tr.row-dup:hover {
  background: #fef3c7 !important;
}
tr.row-dup td {
  border-bottom-color: #fde68a !important;
}

/* Duplicate comparison modal */
.dup-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  z-index: 1500;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4vh 1rem 2rem;
  overflow-y: auto;
  animation: dupFadeIn 0.18s ease;
}
@keyframes dupFadeIn { from { opacity: 0; } to { opacity: 1; } }
.dup-modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 1180px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  animation: dupSlideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes dupSlideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.dup-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.4rem;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #fff;
}
.dup-modal-header h3 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.dup-modal-header .dup-modal-sub {
  font-size: 0.82rem;
  font-weight: 400;
  opacity: 0.92;
  margin-top: 0.15rem;
}
.dup-modal-close {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease;
}
.dup-modal-close:hover { background: rgba(255, 255, 255, 0.32); }
.dup-modal-close svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; fill: none; }

.dup-modal-body {
  padding: 1.25rem 1.4rem 1.5rem;
  background: #fafafa;
  max-height: 70vh;
  overflow-y: auto;
}
.dup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  align-items: stretch;
}
.dup-card {
  background: #fff;
  border: 1.5px solid #fde68a;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.dup-card:hover {
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.18);
  transform: translateY(-2px);
}
.dup-card-img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  background: #f1f5f9;
  display: block;
}
.dup-card-body {
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}
.dup-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #1e293b;
  line-height: 1.3;
  margin: 0;
}
.dup-card-meta {
  font-size: 0.78rem;
  color: #64748b;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
}
.dup-card-meta b { color: #334155; font-weight: 600; }
.dup-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.2rem 0;
  border-bottom: 1px dashed #f1f5f9;
  font-size: 0.82rem;
}
.dup-row:last-child { border-bottom: none; }
.dup-row .dup-row-k {
  color: #64748b;
  flex-shrink: 0;
}
.dup-row .dup-row-v {
  color: #1e293b;
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}
.dup-card-foot {
  padding: 0.7rem 1rem;
  border-top: 1px solid #fef3c7;
  background: #fffbeb;
  display: flex;
  gap: 0.45rem;
  justify-content: space-between;
  align-items: center;
}
.dup-card-id {
  font-size: 0.7rem;
  color: #92400e;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #fef3c7;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}
.dup-card-actions { display: flex; gap: 0.35rem; }
.dup-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.dup-btn svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 2; fill: none; }
.dup-btn-primary { background: var(--primary-color, #e11d48); color: #fff; }
.dup-btn-primary:hover { background: var(--primary-hover, #be123c); }
.dup-btn-ghost { background: #fff; color: #475569; border-color: #cbd5e1; }
.dup-btn-ghost:hover { background: #f1f5f9; }
.dup-btn-danger { background: #fff; color: #dc2626; border-color: #fca5a5; }
.dup-btn-danger:hover { background: #fee2e2; }

.dup-info-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 0.7rem 0.95rem;
  font-size: 0.85rem;
  color: #78350f;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
}
.dup-info-banner svg {
  width: 18px;
  height: 18px;
  stroke: #b45309;
  stroke-width: 2;
  fill: none;
  flex-shrink: 0;
  margin-top: 1px;
}
.dup-info-banner b { color: #92400e; }
.dup-info-banner code {
  background: rgba(245, 158, 11, 0.15);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  font-size: 0.78rem;
}

@media (max-width: 640px) {
  .dup-modal { max-width: 100%; border-radius: 10px; }
  .dup-modal-body { padding: 1rem; }
  .dup-grid { grid-template-columns: 1fr; }
}

/* Dismiss button (in modal header) */
.dup-dismiss-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  background: rgba(255, 255, 255, 0.15);
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}
.dup-dismiss-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.7);
}
.dup-dismiss-btn svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; }
.dup-dismiss-btn.is-restored {
  background: #16a34a;
  border-color: #15803d;
}
.dup-dismiss-btn.is-restored:hover { background: #15803d; }

/* Per-card dismiss button */
.dup-card-dismiss {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.55rem;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}
.dup-card-dismiss:hover { background: #fde68a; }
.dup-card-dismiss svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 2.5; fill: none; }

/* Delta highlight rows */
.dup-delta {
  margin-top: 0.4rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  font-size: 0.78rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}
.dup-delta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.dup-delta-item .lbl { color: #64748b; }
.dup-delta-item .val { font-weight: 700; color: #1e293b; }
.dup-delta-item.match .val { color: #16a34a; }
.dup-delta-item.diff .val { color: #b45309; }
.dup-delta-item.diff .val::before { content: '\0394 '; opacity: 0.6; }

/* Dismissed banner (top of modal) */
.dup-dismissed-banner {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #14532d;
  border-radius: 10px;
  padding: 0.7rem 0.95rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.dup-dismissed-banner svg {
  width: 18px; height: 18px; stroke: #16a34a; stroke-width: 2; fill: none; flex-shrink: 0;
}

/* "จัดการรายการที่ซ่อนไว้" link/button next to main toggle */
.dup-manage-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0 0.6rem;
  height: 30px;
  background: transparent;
  color: #64748b;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
  text-decoration: none;
}
.dup-manage-btn:hover {
  background: #f1f5f9;
  color: #334155;
  border-color: #94a3b8;
}
.dup-manage-btn svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 2; fill: none; }
.dup-manage-btn .mg-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 16px;
  padding: 0 5px;
  background: #94a3b8;
  color: #fff;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
}
.dup-manage-btn.has-count .mg-count { background: #b45309; }

/* Management modal list */
.dup-mgmt-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.dup-mgmt-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}
.dup-mgmt-item .mg-info { flex: 1; min-width: 0; }
.dup-mgmt-item .mg-info .mg-title {
  font-weight: 600;
  color: #1e293b;
  font-size: 0.88rem;
  margin: 0 0 0.2rem 0;
}
.dup-mgmt-item .mg-info .mg-meta {
  font-size: 0.76rem;
  color: #64748b;
}
.dup-mgmt-item .mg-info code {
  background: #f1f5f9;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.74rem;
  color: #475569;
}
.dup-mgmt-actions { display: flex; gap: 0.35rem; }
.dup-mgmt-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: #64748b;
}
.dup-mgmt-empty svg {
  width: 48px;
  height: 48px;
  stroke: #cbd5e1;
  stroke-width: 1.5;
  fill: none;
  margin-bottom: 0.5rem;
}
.dup-mgmt-footer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

/* ============================================================
   AI Smart Auto-Fill — Source indicator badge
   ============================================================ */
.ai-source-rule {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  color: #065f46;
  border: 1px solid #6ee7b7;
}
.ai-source-ai {
  background: linear-gradient(135deg, #ede9fe 0%, #c4b5fd 100%);
  color: #5b21b6;
  border: 1px solid #a78bfa;
}
.ai-source-fallback {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
  border: 1px solid #fbbf24;
}
.ai-status-box {
  margin-top: 0.5rem;
  min-height: 1.5rem;
}
