.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  font-size: 0.9rem;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-muted);
}

.btn-success {
  background: var(--color-success);
  color: white;
}

.btn-danger {
  background: var(--color-danger);
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 1rem;
}

.card-body {
  padding: 1.25rem;
}

.stat-card {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stat-card .stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.stat-card.primary .stat-icon { background: var(--color-primary-light); color: var(--color-primary); }
.stat-card.success .stat-icon { background: #dcfce7; color: var(--color-success); }
.stat-card.warning .stat-icon { background: #fef3c7; color: var(--color-warning); }
.stat-card.info .stat-icon { background: #dbeafe; color: var(--color-info); }

.form-group {
  margin-bottom: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.table-wrapper {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.data-table th,
table.data-table td {
  padding: 0.75rem 1rem;
  text-align: right;
  border-bottom: 1px solid var(--border-color);
}

table.data-table th {
  background: var(--bg-hover);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.82rem;
  white-space: nowrap;
}

table.data-table tbody tr:hover {
  background: var(--bg-hover);
}

table.data-table .actions {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-start;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-draft { background: #e8ecf1; color: #5c6370; }
.badge-finalized { background: #dcfce7; color: #15803d; }
.badge-cancelled { background: #fee2e2; color: #b91c1c; }
.badge-paid { background: #dcfce7; color: #15803d; }
.badge-partial { background: #fef3c7; color: #b45309; }
.badge-unpaid { background: #fee2e2; color: #b91c1c; }
.badge-low-stock { background: #fef3c7; color: #b45309; }

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-bar input {
  max-width: 320px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow: visible;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}

.modal.modal-lg { max-width: 800px; }
.modal.modal-xl { max-width: 1000px; }

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-header h3 { font-size: 1.05rem; }

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
}

.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-shrink: 0;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Toast */
.toast-container {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  min-width: 280px;
  animation: slideInLeft 0.25s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toast.success { border-right: 4px solid var(--color-success); }
.toast.error { border-right: 4px solid var(--color-danger); }
.toast.warning { border-right: 4px solid var(--color-warning); }
.toast.info { border-right: 4px solid var(--color-info); }

@keyframes slideInLeft {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Autocomplete */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-dropdown {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 260px;
  overflow-y: auto;
  z-index: 3000;
  margin-top: 0;
}

.autocomplete-item {
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--bg-hover);
}

.autocomplete-item small {
  display: block;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.autocomplete-empty {
  padding: 0.75rem 0.85rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.search-select-wrapper {
  position: relative;
}

.search-select-native {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
  overflow: hidden;
}

.search-select-input {
  width: 100%;
}

.money-input {
  direction: ltr;
  text-align: left;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* Plate input */
.plate-input {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  direction: ltr;
  justify-content: flex-end;
}

.plate-input input,
.plate-input select {
  width: auto;
  text-align: center;
  font-weight: 600;
  letter-spacing: 1px;
}

.plate-input .plate-part1 { width: 55px; }
.plate-input .plate-letter { width: 50px; }
.plate-input .plate-part2 { width: 65px; }
.plate-input .plate-iran { width: 55px; }

/* Iranian license plate display */
.iran-plate {
  display: inline-flex;
  align-items: stretch;
  border: 2px solid #1a365d;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  color: #111;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1.1;
  vertical-align: middle;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  min-width: 130px;
}

.iran-plate-strip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  background: linear-gradient(180deg, #1e4f9b 0%, #163b78 100%);
  color: #fff;
  padding: 0.2rem 0.35rem;
  min-width: 34px;
  border-left: 1px solid #0f2d5c;
}

.iran-plate-flag {
  font-size: 0.7rem;
  line-height: 1;
}

.iran-plate-label {
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0;
}

.iran-plate-code {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.iran-plate-main {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.25rem 0.55rem;
  background: #fff;
  color: #111;
  flex: 1;
}

.iran-plate-num {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: #111;
}

.iran-plate-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  font-size: 1rem;
  font-weight: 800;
  color: #111;
}

.iran-plate-fallback {
  padding: 0.2rem 0.5rem;
  background: #fff;
  color: #111;
}

.plate-display {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: #fff;
  border: 2px solid #1a365d;
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
  font-weight: 700;
  direction: ltr;
  font-size: 0.9rem;
  color: #111;
}

/* Global search modal */
.global-search-input {
  font-size: 1.1rem;
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
}

.search-results-group h4 {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.5rem 0;
  text-transform: uppercase;
}

.search-result-item {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-result-item:hover {
  background: var(--bg-hover);
}

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

.tab {
  padding: 0.6rem 1rem;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-warning {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
}

.alert-info {
  background: #dbeafe;
  border: 1px solid #93c5fd;
  color: #1e40af;
}

[data-theme="dark"] .alert-warning {
  background: #422006;
  border-color: #92400e;
  color: #fcd34d;
}

[data-theme="dark"] .alert-info {
  background: #1e3a5f;
  border-color: #2563eb;
  color: #93c5fd;
}

/* Vehicle schematic — Body-in-White */
.vehicle-schematic.vs-biw {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.vs-biw-frame {
  position: relative;
  width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #f3ead8;
  border: 1px solid var(--border-color);
  aspect-ratio: 1024 / 400;
}

.vs-biw-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  user-select: none;
  pointer-events: none;
}

.vs-biw-overlay-wrap {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.vs-biw-overlay-wrap .vs-biw-overlay,
.vs-biw-print .vs-biw-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.vs-biw-zone {
  fill: transparent;
  stroke: transparent;
  stroke-width: 0;
  transition: fill 0.2s ease, stroke 0.2s ease;
}

.vs-biw-zone.is-active {
  fill: color-mix(in srgb, var(--color-primary) 42%, transparent);
  stroke: var(--color-primary);
  stroke-width: 2.5;
  stroke-opacity: 0.95;
}

.vs-hint {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
}

.vs-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.6rem;
  min-height: 1.5rem;
  font-size: 0.8rem;
}

.vs-chip {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-primary) 15%, transparent);
  color: var(--color-primary);
  border: 1px solid color-mix(in srgb, var(--color-primary) 35%, transparent);
}

.invoice-zone-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
  color: var(--color-primary);
  margin-left: 0.25rem;
}

.inv-schematic-biw .vs-biw-frame {
  aspect-ratio: 1024 / 400;
  max-width: 100%;
}

.inv-schematic-biw .vs-biw-img {
  width: 100%;
  height: 100%;
  object-fit: fill;
}
