/* Shared DMS dashboard theme */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-3: #f3f4f6;
  --border: #e8eaee;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-secondary: #374151;
  --muted: #6b7280;
  --soft: #9ca3af;
  --green: #059669;
  --green-bg: #ecfdf5;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --accent: #111827;
  --accent-hover: #1f2937;
  --accent-text: #ffffff;
  --focus-ring: rgba(17, 24, 39, 0.06);
  --input-bg: #fafbfc;
  --input-bg-focus: #ffffff;
  --seg-bg: #f3f4f6;
  --row-hover: #fafbfc;
  --row-border: #f0f1f3;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.1);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0c0e12;
  --surface: #14171e;
  --surface-2: #1a1e27;
  --surface-3: #222733;
  --border: #2a303c;
  --border-strong: #3a4252;
  --text: #f3f4f6;
  --text-secondary: #d1d5db;
  --muted: #9ca3af;
  --soft: #6b7280;
  --green: #34d399;
  --green-bg: rgba(16, 185, 129, 0.12);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.12);
  --accent: #f3f4f6;
  --accent-hover: #e5e7eb;
  --accent-text: #0c0e12;
  --focus-ring: rgba(255, 255, 255, 0.08);
  --input-bg: #1a1e27;
  --input-bg-focus: #1f2430;
  --seg-bg: #1a1e27;
  --row-hover: #1a1e27;
  --row-border: #222733;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  background: var(--bg) !important;
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  margin: 0;
  padding-top: 0 !important;
}

.dash {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 28px 56px;
}

.dash-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.dash-top h1 {
  margin: 0 0 4px;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.dash-top p,
.dash-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.dash-top .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.vin-chip {
  display: inline-flex;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 550;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  color: var(--text-secondary);
}

/* Buttons */
.btn-dash {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text) !important;
  font-size: 0.875rem;
  font-weight: 550;
  text-decoration: none;
  border: none;
  white-space: nowrap;
  transition: background 0.15s, opacity 0.15s;
  cursor: pointer;
}

.btn-dash:hover { background: var(--accent-hover); color: var(--accent-text) !important; }

.btn-dash-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-secondary) !important;
  font-size: 0.875rem;
  font-weight: 550;
  text-decoration: none;
  border: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-dash-secondary:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--text) !important;
}

.btn-dash-sm {
  height: 34px;
  padding: 0 12px;
  font-size: 0.8125rem;
  border-radius: 8px;
}

.btn-dash-danger {
  background: var(--surface);
  color: var(--red) !important;
  border: 1px solid var(--border);
}

.btn-dash-danger:hover {
  background: var(--red-bg);
  border-color: var(--red);
  color: var(--red) !important;
}

.btn-group-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.kpi-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.kpi-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 10px;
}

.kpi-label i { font-size: 1rem; color: var(--soft); }

.kpi-value {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.kpi-hint {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--soft);
}

.kpi-value.pos { color: var(--green); }
.kpi-value.neg { color: var(--red); }

/* Panel / card */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden; /* clip children so border-radius is visible */
  margin-bottom: 18px;
}

/* Keep overflow visible for action menus; round child corners instead of clipping */
.panel.panel-menus {
  overflow: visible;
}

.panel.panel-menus > :first-child {
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}

.panel.panel-menus > :last-child {
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

/* Flush tables inside menu panels — round corner cells so fills match the card */
.panel.panel-menus > .panel-body.tight:first-child > .dash-table-wrap:first-child .dash-table thead th:first-child {
  border-top-left-radius: var(--radius);
}
.panel.panel-menus > .panel-body.tight:first-child > .dash-table-wrap:first-child .dash-table thead th:last-child {
  border-top-right-radius: var(--radius);
}
.panel.panel-menus > .panel-body.tight:last-child > .dash-table-wrap:last-child .dash-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: var(--radius);
}
.panel.panel-menus > .panel-body.tight:last-child > .dash-table-wrap:last-child .dash-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: var(--radius);
}
.panel.panel-menus .panel-body.tight > .pager-bar:last-child {
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

/* Vehicle list rows when list is the last child of a menu panel */
.panel.panel-menus > .v-list:last-child > .v-row:last-child {
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.panel-header h2,
.panel-header h3,
.panel-header h5 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}

.panel-header .link-action {
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  border: none;
  background: none;
  padding: 0;
}

.panel-header .link-action:hover { color: var(--text); }

.panel-body {
  padding: 20px 18px;
}

.panel-body.tight { padding: 0; }

.section-title {
  font-size: 0.8rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--soft);
  margin: 4px 0 14px;
}

.section-title.spaced { margin-top: 22px; }

/* Forms */
.form-label {
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control,
.form-select {
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 42px;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--input-bg);
  box-shadow: none !important;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--border-strong);
  background: var(--input-bg-focus);
  box-shadow: 0 0 0 3px var(--focus-ring) !important;
  color: var(--text);
}

.form-control::placeholder {
  color: var(--soft);
}

.form-select option {
  background: var(--surface);
  color: var(--text);
}

.form-text,
.form-text.text-muted {
  color: var(--soft) !important;
  font-size: 0.78rem;
}

.form-check-input {
  border-color: var(--border-strong);
  width: 1.05em;
  height: 1.05em;
  margin-top: 0.2em;
  background-color: var(--input-bg);
}

.form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}

.form-check-input:focus {
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-check-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.input-group-text {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.875rem;
}

.input-group .form-control {
  border-radius: 10px;
}

.nested-section {
  margin-top: 1.25rem;
  padding: 1.25rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.nested-section h4 {
  font-size: 0.95rem;
  font-weight: 650;
  margin: 0 0 1rem;
  color: var(--text);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 18px;
}

.info-item .lbl {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--soft);
  margin-bottom: 3px;
}

.info-item .val {
  font-size: 0.95rem;
  font-weight: 550;
  color: var(--text);
}

.info-item .val.pos { color: var(--green); }
.info-item .val.neg { color: var(--red); }

/* Tabs */
.dash-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--seg-bg);
  border-radius: 12px;
  margin-bottom: 18px;
  border: none;
}

.dash-tabs .nav-link {
  border: none !important;
  border-radius: 9px !important;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 550;
  padding: 9px 14px;
  background: transparent;
}

.dash-tabs .nav-link:hover {
  color: var(--text);
  background: rgba(127, 127, 127, 0.1);
}

.dash-tabs .nav-link.active {
  background: var(--surface) !important;
  color: var(--text) !important;
  box-shadow: var(--shadow);
}

/* Tables */
.dash-table-wrap {
  overflow-x: auto;
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 0.875rem;
}

.dash-table thead th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.dash-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--row-border);
  vertical-align: middle;
  color: var(--text);
}

.dash-table tbody tr:last-child td { border-bottom: none; }
.dash-table tbody tr:hover { background: var(--row-hover); }

.dash-table .pos { color: var(--green); font-weight: 600; }
.dash-table .neg { color: var(--red); font-weight: 600; }

.vehicle-thumb {
  width: 56px;
  height: 42px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
}

.no-thumb {
  width: 56px;
  height: 42px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--soft);
  font-weight: 500;
}

.clickable-vin {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 550;
  color: var(--text-secondary);
  text-decoration: none;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
}

.clickable-vin:hover {
  background: var(--surface-2);
  color: var(--text);
}

.cost-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.cost-summary .kpi { padding: 14px 16px; }
.cost-summary .kpi-value { font-size: 1.2rem; }

.totals-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px 28px;
  padding: 14px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.totals-row .metric .lbl {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--soft);
}

.totals-row .metric .val {
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.totals-row .metric .val.pos { color: var(--green); }
.totals-row .metric .val.neg { color: var(--red); }

.photo-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}

.photo-item {
  width: 160px;
  position: relative;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
  cursor: move;
  transition: all 0.2s;
}

.photo-item.dragging {
  opacity: 0.6;
  transform: scale(0.96);
}

.photo-item.drag-over {
  border: 2px dashed var(--soft);
  background: var(--surface-3);
}

.photo-item img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.photo-item .delete-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(220, 53, 69, 0.92);
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 14px;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
}

.photo-item .drag-handle {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 12px;
  line-height: 24px;
  text-align: center;
  cursor: move;
}

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

.empty-inline {
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.modal-content {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
}

.modal-header {
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
}

.modal-footer {
  border-top: 1px solid var(--border);
  padding: 12px 18px;
}

.modal-title {
  font-size: 1rem;
  font-weight: 650;
  color: var(--text);
}

.btn-close {
  filter: var(--btn-close-filter, none);
}

html[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%);
  opacity: 0.7;
}

@media (max-width: 960px) {
  .kpi-grid,
  .kpi-grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .info-grid { grid-template-columns: repeat(2, 1fr); }
  .cost-summary { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .dash { padding: 18px 14px 40px; }
  .kpi-grid,
  .kpi-grid.cols-3 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-value { font-size: 1.25rem; }
  .info-grid { grid-template-columns: 1fr; }
  .dash-tabs .nav-link { flex: 1; text-align: center; font-size: 0.8rem; padding: 8px 10px; }
}
