:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --primary: #3b5b9b;
  --primary-dark: #2c4c8c;
  --accent: #9b8b7c;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --soft: #f1f5f9;
  --success: #10b981;
  --success-dark: #059669;
  --danger: #ef4444;
  --danger-dark: #dc2626;
}

/* ── Reset & Base ── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

/* ── App Layout ── */
.app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: 240px;
  min-height: 100vh;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* ── Main Content ── */
.main {
  flex: 1;
  padding: 36px 36px;
  background: var(--bg);
  min-width: 0; /* prevent overflow */
}

/* ── Page Header ── */
.header {
  margin-bottom: 28px;
}

.header-content h1 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 6px;
  line-height: 1.2;
}

.header-content p {
  color: var(--muted);
  font-size: 14px;
}

/* ── Cards ── */
.card {
  background: var(--card);
  padding: 24px 28px;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

/* ── Headings ── */
h1 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
}

h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

/* ── Top Controls Card Layout ── */
.sales-top-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.sales-top-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sales-top-item h3 {
  margin-bottom: 0;
}

.sales-top-item .flex {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}

.sales-top-item label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Add Car Form Grid ── */
.grid-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  align-items: start;
}

.grid-form .full-width {
  grid-column: 1 / -1;
}

.file-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-group label {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

/* ── Flex Helpers ── */
.flex {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.align-center {
  align-items: center;
}

/* ── Inputs & Select ── */
input,
select {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  font-size: 14px;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="file"] {
  padding: 8px 12px;
  cursor: pointer;
  color: var(--muted);
}

input::placeholder {
  color: #94a3b8;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 91, 155, 0.12);
}

/* Select specific */
select {
  min-width: 200px;
  width: auto;
  cursor: pointer;
}

/* ── Buttons – General ── */
button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-weight: 600;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 11px 22px;
  box-shadow: 0 6px 16px rgba(59, 91, 155, 0.25);
}

button.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(59, 91, 155, 0.4);
}

button.secondary {
  background: var(--soft);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 11px 22px;
}

button.secondary:hover {
  background: var(--border);
}

/* ── Toggle Add Car Button ── */
.toggle-btn {
  padding: 11px 24px;
  border: 1px solid var(--border);
  background: white;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
  color: var(--text);
}

.toggle-btn:hover {
  border-color: var(--primary);
  background: var(--soft);
}

button.toggle-btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  box-shadow: 0 6px 16px rgba(59, 91, 155, 0.25);
}

button.toggle-btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(59, 91, 155, 0.4);
}

/* ── Variant management buttons ── */
.add-btn {
  padding: 5px 12px;
  font-size: 12px;
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #7dd3fc;
  border-radius: 8px;
  margin-top: 6px;
  width: 100%;
}

.add-btn:hover {
  background: #bae6fd;
}

.edit-btn {
  background: linear-gradient(135deg, var(--success), var(--success-dark));
  color: white;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  margin-left: 6px;
  flex-shrink: 0;
}

.delete-btn {
  background: linear-gradient(135deg, var(--danger), var(--danger-dark));
  color: white;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  margin-left: 4px;
  flex-shrink: 0;
}

/* ── Car Action Buttons ── */
.edit-car-btn {
  background: linear-gradient(135deg, var(--success), var(--success-dark));
  color: white;
  padding: 7px 14px;
  font-size: 13px;
  border-radius: 8px;
  margin-right: 6px;
}

.delete-car-btn {
  background: linear-gradient(135deg, var(--danger), var(--danger-dark));
  color: white;
  padding: 7px 14px;
  font-size: 13px;
  border-radius: 8px;
}

/* ── Variant List ── */
.variant-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 2px 0;
  min-width: 160px;
}

.variant-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid #e5e7eb;
  gap: 6px;
}

.variant-item > span {
  flex: 1;
}

.variant-item.empty {
  color: var(--muted);
  font-style: italic;
  justify-content: center;
  padding: 10px;
  font-size: 12px;
  border-style: dashed;
}

/* ── Table ── */
.table-wrapper {
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

thead {
  background: var(--soft);
  position: sticky;
  top: 0;
}

th {
  padding: 13px 16px;
  text-align: left;
  font-weight: 700;
  font-size: 13px;
  color: #334155;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 14px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: #fafbff;
}

td.actions {
  white-space: nowrap;
  vertical-align: middle;
}

/* ── Hints ── */
.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Modal ── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: white;
  padding: 28px;
  border-radius: 20px;
  width: 420px;
  max-width: 90%;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25);
}

.modal-content.edit-modal {
  width: 540px;
  max-height: 88vh;
  overflow-y: auto;
}

.modal-header {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── Form Groups (Modal) ── */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input {
  width: 100%;
}

/* Variant modal input */
#variantInput {
  width: 100%;
  margin-bottom: 4px;
}

/* ── Hidden ── */
.hidden {
  display: none !important;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .main {
    padding: 24px 20px;
  }

  .grid-form {
    grid-template-columns: repeat(2, 1fr);
  }

  .sales-top-grid {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .main {
    padding: 20px 16px;
  }

  .grid-form {
    grid-template-columns: 1fr;
  }

  .sales-top-grid {
    flex-direction: column;
    align-items: stretch;
  }

  .modal-content,
  .modal-content.edit-modal {
    width: 92%;
    padding: 20px;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
  }

  thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  tr {
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
  }

  td {
    border: none;
    border-bottom: 1px solid var(--border);
    position: relative;
    padding-left: 50%;
  }

  td:before {
    position: absolute;
    top: 12px;
    left: 16px;
    width: 45%;
    padding-right: 10px;
    white-space: nowrap;
    font-weight: 600;
    font-size: 12px;
    color: var(--muted);
    content: attr(data-label);
  }
}