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

@font-face {
  font-family: 'DrukWide';
  src: url('./font/DrukWide-SuperItalic-Trial.otf') format('opentype');
  font-weight: normal;
  font-style: italic;
  font-display: swap;
}

:root {
  /* Light Mode - Minimalist Black & White Palette */
  --bg-primary: #ffffff;
  --bg-secondary: #fafafa;
  --card-bg: #ffffff;
  --card-border: #e0e0e0;
  --text-primary: #000000;
  --text-secondary: #666666;
  --text-muted: #999999;
  --hover-bg: #f5f5f5;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);

  /* Profit Colors */
  --profit-positive: #00a86b;
  --profit-negative: #dc143c;
}

/* Dark Mode - Aplicar a html y body para evitar flash */
html.dark-mode,
body.dark-mode,
.dark-mode body {
  --bg-primary: #1a1a1a;
  --bg-secondary: #0f0f0f;
  --card-bg: #1a1a1a;
  --card-border: #333333;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --text-muted: #666666;
  --hover-bg: #252525;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.5);
}

body.dark-mode .cars-table thead,
.dark-mode .cars-table thead {
  border-bottom: 1px solid var(--card-border);
}

body.dark-mode .btn-primary,
.dark-mode .btn-primary {
  background: #ffffff;
  color: #000000;
}

body.dark-mode .btn-primary:hover,
.dark-mode .btn-primary:hover {
  background: #e0e0e0;
}

body.dark-mode .btn-secondary,
.dark-mode .btn-secondary {
  background: #1a1a1a;
  color: #ffffff;
}

body.dark-mode .form-group input:focus,
body.dark-mode .form-group select:focus,
body.dark-mode .form-group textarea:focus,
.dark-mode .form-group input:focus,
.dark-mode .form-group select:focus,
.dark-mode .form-group textarea:focus {
  border-color: #ffffff;
  box-shadow: 0 0 0 1px #ffffff;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  background: var(--bg-secondary);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
  position: relative;
}

/* Sidebar Styles */
.sidebar {
  position: fixed;
  top: 0;
  left: -280px;
  width: 280px;
  height: 100vh;
  background: var(--card-bg);
  border-right: 1px solid var(--card-border);
  box-shadow: var(--shadow-md);
  transition: left 0.3s ease;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar.active {
  left: 0;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.sidebar-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  flex: 1;
}

.sidebar-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 2px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-close svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-secondary);
}

.sidebar-close:hover {
  background: var(--hover-bg);
}

.sidebar-close:hover svg {
  stroke: var(--text-primary);
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: var(--hover-bg);
  color: var(--text-primary);
  border-left-color: #000000;
  font-weight: 600;
}

body.dark-mode .sidebar-link.active,
.dark-mode .sidebar-link.active {
  border-left-color: #ffffff;
}

.sidebar-link svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  transition: transform 0.2s ease;
}

.sidebar-link:hover svg {
  transform: scale(1.1);
}

.sidebar-link .badge {
  margin-left: auto;
  background: #000000;
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

body.dark-mode .sidebar-link .badge,
.dark-mode .sidebar-link .badge {
  background: #ffffff;
  color: #000000;
}

.sidebar-divider {
  height: 1px;
  background: var(--card-border);
  margin: 0.5rem 1.5rem;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--card-border);
  margin-top: auto;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem;
  background: var(--hover-bg);
  border-radius: 8px;
  transition: background-color 0.2s ease;
  cursor: pointer;
  margin-bottom: 0;
}

.sidebar-user:hover {
  background: var(--card-border);
}

.sidebar-user-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%); */
  border-radius: 10px;
  position: relative;
}

.sidebar-user>.sidebar-user-icon svg {
  width: 20px;
  height: 20px;
  stroke: var(--bg-primary);
  stroke-width: 2.5;
}

.sidebar-user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.sidebar-user .sidebar-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.25s ease;
}

.sidebar-user-name {
  font-size: 0.813rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.sidebar-user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* User Dropdown */
.sidebar-user-dropdown {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.2s ease;
  padding: 0;
}

.sidebar-user-dropdown.active {
  max-height: 180px;
  opacity: 1;
  padding-top: 0.5rem;
}

.sidebar-user-dropdown a,
.sidebar-user-dropdown button {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-secondary);
  text-decoration: none;
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sidebar-user-dropdown a svg,
.sidebar-user-dropdown button svg {
  width: 16px;
  height: 16px;
  stroke: var(--text-muted);
  transition: stroke 0.15s;
}

.sidebar-user-dropdown a:hover,
.sidebar-user-dropdown button:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.sidebar-user-dropdown a.active {
  background: var(--hover-bg);
  color: var(--text-primary);
  font-weight: 600;
}

.sidebar-user-dropdown a:hover svg,
.sidebar-user-dropdown button:hover svg,
.sidebar-user-dropdown a.active svg {
  stroke: var(--text-primary);
}

.sidebar-user-dropdown .sidebar-logout-item {
  color: #dc2626;
  margin-top: 0.25rem;
  border-top: 1px solid var(--card-border);
  border-radius: 0 0 7px 7px;
  padding-top: 0.6rem;
}

.sidebar-user-dropdown .sidebar-logout-item svg {
  stroke: #dc2626;
}

.sidebar-user-dropdown .sidebar-logout-item:hover {
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
}

.sidebar-user-dropdown .sidebar-logout-item:hover svg {
  stroke: #b91c1c;
}

/* Legacy logout button (keep for backward compat) */
.logout-btn {
  display: none;
}

/* Sidebar Overlay */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1050;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* Menu Toggle Button */
.menu-toggle {
  position: fixed;
  top: 1rem;
  left: 1rem;
  width: 48px;
  height: 48px;
  background: #000000;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
  z-index: 1000;
}

.menu-toggle:hover {
  background: #1a1a1a;
  transform: scale(1.05);
}

.menu-toggle svg {
  width: 24px;
  height: 24px;
  stroke: white;
  stroke-width: 2;
}

body.dark-mode .menu-toggle,
.dark-mode .menu-toggle {
  background: #ffffff;
}

body.dark-mode .menu-toggle:hover,
.dark-mode .menu-toggle:hover {
  background: #e0e0e0;
}

body.dark-mode .menu-toggle svg,
.dark-mode .menu-toggle svg {
  stroke: #000000;
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  padding-left: 5rem;
  transition: padding-left 0.3s ease;
}

@media (max-width: 1200px) {
  .container {
    max-width: 100%;
  }
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 3rem;
  margin-top: 1rem;
}

.header-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-logo img {
  padding-top: 3px;
  width: 50px;
  height: 50px;
  object-fit: contain;
  border-radius: 10px;
}

.header h1 {
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.02em;
}

.header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 400;
  margin: 0;
}

/* Dark Mode Toggle */
.dark-mode-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 4px;
  padding: 0.75rem 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  box-shadow: var(--shadow-md);
}

.dark-mode-toggle svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-primary);
}

.dark-mode-toggle:hover {
  background: var(--hover-bg);
}

/* Card */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 4px;
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  color: var(--text-primary);
  font-weight: 600;
}

.card-title svg {
  width: 24px;
  height: 24px;
  stroke: var(--text-primary);
}

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

.card-header .card-title {
  margin-bottom: 0;
}

/* Collapsible Card Header */
.card-header-collapsible {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  margin-bottom: 0;
  padding: 0.5rem;
  margin: -0.5rem;
  border-radius: 4px;
}

.card-header-collapsible:hover {
  background: var(--hover-bg);
}

.card-header-collapsible .card-title {
  margin-bottom: 0;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

.collapse-hint {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: normal;
}

.collapse-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.3s ease;
  color: var(--text-secondary);
}

.collapse-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.collapse-btn svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  transition: transform 0.3s ease;
}

.collapse-btn.expanded svg {
  transform: rotate(180deg);
}

/* Collapsible Content */
.collapsible-content {
  max-height: 10000px;
  overflow: hidden;
  transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.4s ease,
    margin-top 0.4s ease;
  opacity: 1;
  margin-top: 1.5rem;
}

.collapsible-content.collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  pointer-events: none;
}

/* Button Styles */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 2px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.btn-primary {
  background: #000000;
  color: white;
}

.btn-primary:hover {
  background: #1a1a1a;
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-primary);
  border: 1px solid var(--card-border);
}

.btn-secondary:hover {
  background: var(--hover-bg);
}

.form-actions {
  margin-top: 2rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

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

@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-primary);
  border: 1px solid var(--card-border);
  border-radius: 2px;
  padding: 0.75rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: 'Inter', sans-serif;
  transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #000000;
  box-shadow: 0 0 0 1px #000000;
}

.form-group input::placeholder {
  color: var(--text-muted);
}

/* Recambios Input Group */
.recambios-input-group {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.recambio-nombre {
  flex: 2;
  min-width: 0;
}

.recambio-precio {
  flex: 1;
  min-width: 0;
}

.recambio-btn {
  padding: 0.5rem 1rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Table Styles */
/* ==========================================
   Inventory Card Header
   ========================================== */
.inv-card {
  border-radius: 12px;
}

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

.inv-card-title-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.inv-card-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-radius: 8px;
}

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

html:not(.dark-mode) .inv-card-icon svg {
  stroke: #374151;
}

html.dark-mode .inv-card-icon svg {
  stroke: #d1d5db;
}

.inv-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.inv-card-count {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ==========================================
   Inventory Table
   ========================================== */
.table-container {
  overflow-x: auto;
  margin-top: 0.5rem;
}

.cars-table {
  width: 100%;
  border-collapse: collapse;
}

.cars-table thead {
  border-bottom: 1px solid var(--card-border);
}

.cars-table th {
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}

.th-money {
  text-align: right;
  width: 90px;
}

.cars-table th:last-child,
.cars-table td:last-child {
  width: 40px;
  padding-right: 0.5rem;
}

.th-right {
  text-align: right;
}

.th-center {
  text-align: center;
}

.cars-table tbody tr {
  border-bottom: 1px solid var(--card-border);
  transition: background 0.12s ease;
  cursor: pointer;
}

.cars-table tbody tr:last-child {
  border-bottom: none;
}

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

.cars-table td {
  padding: 0.6rem 0.75rem;
  color: var(--text-primary);
  font-size: 0.8rem;
  vertical-align: middle;
}

.td-right {
  text-align: right;
}

.td-center {
  text-align: center;
}

/* Vehicle cell with thumb */
.inv-vehicle-cell {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.inv-row-thumb {
  width: 36px;
  height: 36px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
}

.inv-row-thumb-logo {
  object-fit: contain;
  background: var(--bg-secondary);
  padding: 4px;
}

.inv-row-thumb-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 7px;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.inv-row-thumb-placeholder svg {
  width: 14px;
  height: 14px;
}

html:not(.dark-mode) .inv-row-thumb-placeholder svg {
  stroke: #d1d5db;
}

html.dark-mode .inv-row-thumb-placeholder svg {
  stroke: #4b5563;
}

.inv-vehicle-info {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}

.inv-vehicle-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.inv-vehicle-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.inv-matricula {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* Price display */
.inv-price {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--text-primary);
}

/* Profit cell */
.inv-profit-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.05rem;
}

.inv-profit-pct {
  font-size: 0.65rem;
  font-weight: 600;
}

.profit-positive {
  color: var(--profit-positive) !important;
  font-weight: 600;
}

.profit-estimated {
  color: #3b82f6 !important;
  font-weight: 600;
}

.inv-profit-est {
  font-size: 0.6rem;
  font-weight: 600;
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.profit-negative {
  color: var(--profit-negative) !important;
  font-weight: 600;
}

/* Date cells */
.inv-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Stock pill */
.inv-stock-pill {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-radius: 5px;
  font-variant-numeric: tabular-nums;
}

/* Etiqueta ambiental */
.inv-etiqueta-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.inv-etiqueta-empty {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Row More Button & Dropdown */
.inv-more-wrap {
  position: relative;
  display: flex;
  justify-content: flex-end;
}

.inv-more-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.inv-more-btn svg {
  width: 15px;
  height: 15px;
}

html:not(.dark-mode) .inv-more-btn svg {
  stroke: #9ca3af;
}

html.dark-mode .inv-more-btn svg {
  stroke: #6b7280;
}

.inv-more-btn:hover,
.cars-table tbody tr:hover .inv-more-btn {
  border-color: var(--card-border);
  background: var(--bg-secondary);
}

html:not(.dark-mode) .inv-more-btn:hover svg {
  stroke: #374151;
}

html.dark-mode .inv-more-btn:hover svg {
  stroke: #d1d5db;
}

.inv-row-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  z-index: 100;
  background: var(--bg-primary);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 0.3rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  min-width: 130px;
  opacity: 0;
  transform: translateY(-4px) scale(0.97);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.inv-row-menu.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Menú con position:fixed - no crea scroll ni se recorta */
.inv-row-menu.inv-row-menu-fixed {
  position: fixed;
  right: auto;
  top: auto;
  bottom: auto;
  left: auto;
  margin: 0;
  transform: translateY(-4px) scale(0.97);
}

.inv-row-menu.inv-row-menu-fixed.visible {
  transform: translateY(0) scale(1);
}

.dark-mode .inv-row-menu {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.inv-row-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.65rem;
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: background 0.12s ease;
  text-align: left;
}

.inv-row-menu-item:hover {
  background: var(--hover-bg);
}

.inv-row-menu-item svg {
  width: 13px;
  height: 13px;
}

html:not(.dark-mode) .inv-row-menu-item svg {
  stroke: #6b7280;
}

html.dark-mode .inv-row-menu-item svg {
  stroke: #9ca3af;
}

.inv-row-menu-danger {
  color: #ef4444;
}

.inv-row-menu-danger svg {
  stroke: #ef4444 !important;
}

.inv-row-menu-danger:hover {
  background: rgba(239, 68, 68, 0.06);
}

/* Empty state */
.inv-empty-td {
  padding: 2.5rem 1rem !important;
}

.inv-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
}

.inv-empty svg {
  width: 24px;
  height: 24px;
  opacity: 0.3;
}

html:not(.dark-mode) .inv-empty svg {
  stroke: #9ca3af;
}

html.dark-mode .inv-empty svg {
  stroke: #6b7280;
}

.inv-empty span {
  font-size: 0.78rem;
}



/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-primary);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 1.75rem;
  max-width: 780px;
  width: 92%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
}

.modal-content.vehicle-modal-content {
  max-width: 560px;
}

.dark-mode .modal-content {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

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

.modal-header h2 {
  font-size: 1.5rem;
  color: var(--text-primary);
  font-weight: 600;
}

.close-btn {
  /* background: var(--hover-bg);
    border: 1px solid var(--card-border);
    width: 36px;
    height: 36px;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center; */
  background: white !important;
  color: #0a0a0a !important;
  border: 1px solid #141515 !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.close-btn:hover {
  background: rgba(220, 38, 38, 0.1) !important;
  color: #dc2626 !important;
  border-color: #dc2626 !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.close-btn:hover svg {
  stroke: #f61414;
}

.dark-mode .close-btn {
  background: #2d3748 !important;
  color: #ffffff !important;
  border-color: #ffffff !important;
}

body.dark-mode .close-btn:hover,
.dark-mode .close-btn:hover {
  background: rgba(220, 38, 38, 0.1) !important;
  color: #f87171 !important;
  border-color: #dc2626 !important;
}

/* body.dark-mode .close-btn:hover svg,
.dark-mode .close-btn:hover svg {
    stroke: #000000;
} */

/* Profile Details */
.profile-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}

.detail-item {
  background: var(--bg-secondary);
  padding: 1.25rem;
  border-radius: 2px;
  border: 1px solid var(--card-border);
}

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

.detail-value {
  color: var(--text-primary);
  font-size: 1.125rem;
  font-weight: 600;
}

/* Color del precio de venta según el modo */
html:not(.dark-mode) .detail-value.highlight {
  color: #000000;
}

html.dark-mode .detail-value.highlight {
  color: #ffffff;
}

/* Summary Card (compact vehicle modal) */
.summary-badge {
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.summary-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.summary-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.summary-cell {
  text-align: center;
  padding: 0.7rem;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.summary-cell-bordered {
  background: transparent;
  border: 1px solid var(--card-border);
}

.summary-cell-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  margin-bottom: 0.2rem;
  font-weight: 500;
}

.summary-cell-value {
  font-weight: 700;
  font-size: 0.95rem;
}

.summary-profit {
  padding: 0.8rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1px solid;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.summary-grid-dates {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.summary-date-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.summary-date-item strong {
  color: var(--text-primary);
  font-weight: 600;
}

.summary-client-card {
  padding: 1rem;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.summary-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--text-primary);
  color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}

.summary-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.summary-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.action-row-top {
  display: flex;
  gap: 0.5rem;
}

.action-row-top .action-btn {
  flex: 1;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 0.85rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  border: 1.5px solid var(--card-border);
  font-family: inherit;
  white-space: nowrap;
}

.action-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.action-btn-outline {
  background: transparent;
  color: var(--text-primary);
}

.action-btn-outline:hover {
  background: var(--hover-bg);
  border-color: var(--text-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.action-btn-solid {
  background: var(--text-primary);
  color: var(--bg-primary);
  border-color: var(--text-primary);
}

.action-btn-solid:hover {
  opacity: 0.88;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.action-btn-full {
  width: 100%;
}

/* Stats Tabs */
.stats-tabs-container {
  margin-bottom: 2rem;
}

.stats-tabs {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-secondary);
  padding: 0.5rem;
  border-radius: 12px;
  border: 1px solid var(--card-border);
}

.stats-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.stats-tab svg {
  width: 18px;
  height: 18px;
  transition: transform 0.2s ease;
}

.stats-tab:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.stats-tab.active {
  background: var(--card-bg);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.stats-tab.active svg {
  transform: scale(1.1);
}

.stats-tab-content {
  animation: fadeIn 0.3s ease;
}

.stats-tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Charts Row for Client Stats */
.charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.chart-card {
  padding: 2rem;
  position: relative;
  min-height: 350px;
}

.chart-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  font-size: 1.25rem;
  color: var(--text-primary);
  font-weight: 600;
}

.chart-title svg {
  width: 24px;
  height: 24px;
  stroke: var(--text-primary);
}

.chart-card canvas {
  max-height: 300px !important;
  width: 100% !important;
  display: block !important;
}

@media (max-width: 768px) {
  .charts-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .chart-card {
    padding: 1.5rem;
    min-height: 300px;
  }

  .chart-card canvas {
    max-height: 250px;
  }
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 2rem;
}

@media (max-width: 1400px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .stats-tabs {
    flex-direction: column;
    gap: 0.25rem;
  }

  .stats-tab {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }

  .stats-tab span {
    font-size: 0.875rem;
  }
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 1.5rem;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: relative;
  overflow: hidden;
}

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

.stat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.stat-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--hover-bg);
  border-radius: 8px;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.stat-icon svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-primary);
  stroke-width: 2;
}

.stat-icon.profit-positive {
  background: rgba(0, 168, 107, 0.1);
}

.stat-icon.profit-positive svg {
  stroke: var(--profit-positive);
}

.stat-icon.profit-negative {
  background: rgba(220, 20, 60, 0.1);
}

.stat-icon.profit-negative svg {
  stroke: var(--profit-negative);
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  line-height: 1.2;
}

.stat-value {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.stat-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.stat-detail {
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  opacity: 0.9;
}

.stat-footer {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--card-border);
}

.stat-detail {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.stat-detail.text-muted {
  color: var(--text-muted);
}

.stat-detail.profit-positive {
  color: var(--profit-positive);
  font-weight: 500;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.empty-state-icon {
  margin-bottom: 1rem;
  opacity: 0.4;
  display: flex;
  justify-content: center;
}

.empty-state-icon svg {
  width: 60px;
  height: 60px;
  stroke: var(--text-muted);
}

.empty-state-text {
  font-size: 1.125rem;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--card-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Sidebar Scrollbar */
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--card-border);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Filter Section */
/* Filters Section */
.filters-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.filters-search-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.search-group {
  position: relative;
  flex: 1;
}

.search-group .search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  stroke: var(--text-muted);
  pointer-events: none;
}

.search-group input {
  width: 100%;
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  background: var(--bg-primary);
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-group input::placeholder {
  color: var(--text-muted, #aaa);
  font-weight: 400;
}

.search-group input:hover {
  border-color: var(--text-muted, #999);
}

.search-group input:focus {
  outline: none;
  border-color: #000000;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.dark-mode .search-group input:focus {
  border-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.btn-filter-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  background: var(--bg-primary);
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-filter-clear:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
  background: var(--hover-bg);
}

.btn-filter-clear svg {
  width: 15px;
  height: 15px;
}

.filters-selects-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-pill {
  flex: 1 1 0;
  min-width: 110px;
}

.filter-pill select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 0.45rem 2rem 0.45rem 0.7rem;
  background: var(--bg-primary);
  border: 1.5px solid var(--card-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-pill select:hover {
  border-color: var(--text-muted, #999);
}

.filter-pill select:focus {
  outline: none;
  border-color: #000000;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.06);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23000000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.dark-mode .filter-pill select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.dark-mode .filter-pill select:focus {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.filters-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.results-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 1024px) {
  .container {
    padding: 1.5rem;
    padding-left: 5rem;
  }

  .menu-toggle {
    top: 0.75rem;
    left: 0.75rem;
  }

  .dark-mode-toggle {
    top: 0.75rem;
    right: 0.75rem;
  }

  .card {
    padding: 1.5rem;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .card-header .btn-primary {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 1rem;
    padding-left: 1rem;
    padding-top: 4rem;
  }

  .header {
    margin-bottom: 2rem;
  }

  .menu-toggle {
    top: 0.5rem;
    left: 0.5rem;
    width: 44px;
    height: 44px;
  }

  .menu-toggle svg {
    width: 22px;
    height: 22px;
  }

  .dark-mode-toggle {
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.65rem 0.8rem;
  }

  .sidebar {
    width: 260px;
    left: -260px;
  }

  .header-logo {
    flex-direction: column;
    gap: 0.5rem;
  }

  .header-logo img {
    width: 40px;
    height: 40px;
  }

  .header h1 {
    font-size: 1.75rem;
  }

  .header p {
    font-size: 0.85rem;
    padding: 0 1rem;
  }


  .card {
    padding: 1.25rem;
  }

  .card-title {
    font-size: 1.25rem;
  }

  .card-title svg {
    width: 20px;
    height: 20px;
  }

  .collapse-btn svg {
    width: 20px;
    height: 20px;
  }

  .collapse-hint {
    font-size: 0.7rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .form-group {
    width: 100%;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .btn {
    padding: 0.65rem 1.25rem;
    font-size: 0.8rem;
  }

  /* Recambios section responsive */
  .recambios-input-group {
    flex-direction: column;
    gap: 0.75rem;
  }

  .recambio-nombre,
  .recambio-precio {
    flex: none;
    width: 100%;
  }

  .recambio-btn {
    width: 100%;
    justify-content: center;
  }

  #recambiosContainer {
    max-width: 100%;
    overflow-x: hidden;
  }

  #recambiosContainer>div {
    flex-direction: column;
    gap: 0.5rem;
  }

  #recambiosContainer button {
    width: 100%;
  }

  .btn-text {
    display: inline;
  }

  .modal-content {
    padding: 1.25rem;
    width: 95%;
  }

  .modal-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .modal-header h2 {
    font-size: 1.1rem;
    flex: 1;
    min-width: calc(100% - 50px);
  }

  .modal-header h2 svg {
    width: 20px;
    height: 20px;
  }

  .profile-details {
    grid-template-columns: 1fr;
  }

  .summary-grid-3 {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
  }

  .summary-grid-dates {
    flex-direction: column;
    gap: 0.4rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .stat-card {
    padding: 1.25rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .stat-icon {
    width: 36px;
    height: 36px;
  }

  .stat-icon svg {
    width: 18px;
    height: 18px;
  }

  .filters-selects-row {
    flex-direction: column;
  }

  .filter-pill {
    width: 100%;
  }

  .table-container {
    margin-top: 0.5rem;
  }

  .cars-table th,
  .cars-table td {
    padding: 0.5rem;
  }

  .modal-content .btn {
    flex: 1;
    min-width: 140px;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0.75rem;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .header p {
    font-size: 0.8rem;
  }

  .card {
    padding: 1rem;
    border-radius: 2px;
  }

  .card-title {
    font-size: 1.1rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .form-group {
    width: 100%;
  }

  .form-group label {
    font-size: 0.7rem;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    padding: 0.65rem;
    font-size: 0.8rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .btn {
    padding: 0.6rem 1rem;
    font-size: 0.75rem;
    gap: 0.4rem;
    width: 100%;
    justify-content: center;
  }

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

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-label {
    font-size: 0.7rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .stat-icon {
    width: 32px;
    height: 32px;
  }

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

  .stat-detail {
    font-size: 0.75rem;
  }

  .modal-content {
    padding: 1rem;
    width: 98%;
  }

  .modal-header h2 {
    font-size: 1rem;
  }

  .detail-item {
    padding: 1rem;
  }

  .detail-value {
    font-size: 1rem;
  }

  .cars-table {
    min-width: 700px;
  }

  .cars-table th,
  .cars-table td {
    padding: 0.45rem 0.4rem;
  }

  .inv-row-thumb,
  .inv-row-thumb-placeholder {
    width: 28px;
    height: 28px;
  }

  .empty-state {
    padding: 2rem 1rem;
  }

  .empty-state-icon svg {
    width: 45px;
    height: 45px;
  }

  .detail-label {
    font-size: 0.65rem;
  }

  /* Recambios responsive */
  .recambios-input-group {
    flex-direction: column;
    gap: 0.75rem;
  }

  .recambio-nombre,
  .recambio-precio {
    flex: none;
    width: 100%;
  }

  .recambio-btn {
    width: 100%;
    justify-content: center;
  }

  #recambiosContainer {
    max-width: 100%;
    overflow-x: hidden;
  }

  #recambiosContainer>div {
    flex-direction: column;
  }

  #recambiosContainer button {
    width: 100%;
  }

  .filters-selects-row {
    flex-direction: column;
  }

  .filter-pill {
    width: 100%;
  }
}

.sidebar-link {
  position: relative;
}


/* Page Header Styles (for añadir-coche.html) */
.page-header {
  text-align: center;
  margin-bottom: 2rem;
  animation: slideDown 0.3s ease;
}

.page-header-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
}

.page-header-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  border-radius: 12px;
}

.page-header-icon svg {
  width: 28px;
  height: 28px;
  stroke: var(--bg-primary);
  stroke-width: 2;
}

.page-header h1 {
  margin-top: 0.5rem;
  font-size: 2rem;
  color: var(--text-primary);
}

.page-header .page-subtitle {
  max-width: 600px;
  margin: 0 auto;
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Alert Container Styles */
.alert-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 400px;
}

.alert {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-left: 4px solid;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease-out;
}

.alert-success {
  border-left-color: var(--success);
}

.alert-error {
  border-left-color: var(--danger);
}

.alert-warning {
  border-left-color: #ff9800;
}

.alert-info {
  border-left-color: var(--primary);
}

.alert svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.alert-success svg {
  stroke: var(--success);
}

.alert-error svg {
  stroke: var(--danger);
}

.alert-warning svg {
  stroke: #ff9800;
}

.alert-info svg {
  stroke: var(--primary);
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }

  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

@media (max-width: 768px) {
  .page-header-icon {
    width: 48px;
    height: 48px;
  }

  .page-header-icon svg {
    width: 24px;
    height: 24px;
  }

  .page-header h1 {
    font-size: 1.5rem;
  }

  .alert-container {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }
}

/* ===============================================
   CLIENTES SIDEBAR SECTION
   =============================================== */

.sidebar-clientes-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
}

.sidebar-clientes-toggle .sidebar-chevron {
  position: absolute;
  right: 1rem;
  width: 14px;
  height: 14px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  opacity: 0.5;
}

.sidebar-clientes-toggle:hover .sidebar-chevron {
  opacity: 1;
}

.sidebar-clientes-toggle.active .sidebar-chevron {
  transform: rotate(180deg);
  opacity: 1;
}

.sidebar-clientes-dropdown {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.25s ease,
    padding 0.25s ease;
  opacity: 0;
  padding: 0;
  margin: 0;
}

.sidebar-clientes-dropdown[style*="display: block"],
.sidebar-clientes-dropdown.active {
  max-height: 300px;
  opacity: 1;
  padding: 0.5rem 0;
  margin: 0.25rem 0 0.5rem 0;
}

.dark-mode .sidebar-clientes-dropdown {
  border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-clientes-dropdown:not([style*="display: none"]) {
  border-left: 1px solid rgba(0, 0, 0, 0.05);
}

.sidebar-docs-dropdown,
.sidebar-servicios-dropdown {
  padding: 0.5rem 0;
  margin: 0.25rem 0 0.5rem 0;
  border-left: 1px solid rgba(0, 0, 0, 0.05);
  margin-left: 1.25rem;
}

.dark-mode .sidebar-docs-dropdown,
.dark-mode .sidebar-servicios-dropdown {
  border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-sublink {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem 0.625rem 1.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 6px;
  margin: 0.125rem 0.5rem;
  position: relative;
  font-size: 0.875rem;
}

.sidebar-sublink::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 60%;
  background: var(--text-primary);
  border-radius: 0 2px 2px 0;
  transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-sublink:hover {
  background-color: var(--hover-bg);
  color: var(--text-primary);
  padding-left: 1.75rem;
}

.sidebar-sublink:hover::before {
  width: 3px;
}

.sidebar-sublink.active {
  background-color: var(--hover-bg);
  color: var(--text-primary);
  font-weight: 500;
  padding-left: 1.75rem;
}

.sidebar-sublink.active::before {
  width: 3px;
}

.sidebar-sublink svg {
  width: 16px;
  height: 16px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.sidebar-sublink:hover svg,
.sidebar-sublink.active svg {
  opacity: 1;
}

.sidebar-count {
  margin-left: auto;
  background: var(--text-muted);
  color: var(--bg-primary);
  padding: 0.125rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
  transition: all 0.2s ease;
}

.sidebar-sublink:hover .sidebar-count,
.sidebar-sublink.active .sidebar-count {
  background: var(--text-primary);
  transform: scale(1.05);
}

.dark-mode .sidebar-count {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.dark-mode .sidebar-sublink:hover .sidebar-count,
.dark-mode .sidebar-sublink.active .sidebar-count {
  background: rgba(255, 255, 255, 0.3);
}
