/* Premium VinFast Quotation Web App Stylesheet */

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

:root {
  /* Dark Mode Palette (Default) */
  --bg: #0b111e;
  --surface: #151e30;
  --surface-hover: #1e2a42;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: #2563eb;
  --text: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #10b981;
  --accent: #f59e0b;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  
  --font: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Mode Override */
[data-theme="light"] {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --border: rgba(0, 0, 0, 0.08);
  --border-focus: #1d4ed8;
  --text: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --secondary: #059669;
  
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
}

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

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: var(--transition);
  line-height: 1.5;
}

/* App Header Styling */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-md);
}

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

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #ffffff;
  border-radius: var(--radius-md);
  font-weight: 800;
  font-size: 1.15rem;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.header-title h1 {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, var(--text), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-title p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.table-contact-banner {
  background: rgba(245, 158, 11, 0.04);
  border: 1px dashed rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-md);
  padding: 0.65rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}

.table-contact-banner .contact-name {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.table-contact-banner .contact-phone {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 0.05em;
  animation: phoneBlink 1.2s ease-in-out infinite alternate;
}

@keyframes phoneBlink {
  0% {
    opacity: 0.35;
    text-shadow: 0 0 2px rgba(245, 158, 11, 0.1);
  }
  100% {
    opacity: 1;
    text-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
  }
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.theme-toggle:hover {
  background: var(--surface-hover);
}

/* Centered Layout Container */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.calculator-container {
  display: flex;
  flex-direction: column;
}

/* Segmented Toggle Control */
.mode-switcher {
  display: flex;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.25rem;
  margin-bottom: 1rem;
  gap: 0.25rem;
  box-shadow: var(--shadow-md);
}

.switcher-btn {
  flex: 1;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.switcher-btn.active {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.switcher-btn:hover:not(.active) {
  background-color: var(--surface-hover);
  color: var(--text);
}

/* Card Panel Layout */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-xl);
  transition: var(--transition);
}

/* View Sections */
.view-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.view-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.view-title {
  font-size: 1.05rem;
  font-weight: 800;
}

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

.view-body {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .view-body {
    grid-template-columns: 1fr;
  }
}

.setup-form, .result-details {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Form Inputs styling */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

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

.form-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.form-input, .form-select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  padding-right: 2.25rem;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  outline: none;
  transition: var(--transition);
  text-align: right;
}

[data-theme="light"] .form-input,
[data-theme="light"] .form-select {
  background-color: rgba(0, 0, 0, 0.01);
}

.form-select {
  text-align: left;
  text-align-last: left;
  appearance: none;
  cursor: pointer;
}

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

.form-input:focus, .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.input-suffix {
  position: absolute;
  right: 0.9rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 700;
  pointer-events: none;
}

/* Suffix spacing adjustments to prevent text overlapping */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.input-wrapper .form-input {
  padding-right: 2.75rem; /* Space for short suffixes (đ, %) */
}
.input-wrapper.suffix-long .form-input {
  padding-right: 4.5rem;  /* Space for long suffixes (tháng) */
}

/* Compact grid for fee inputs */
.grid-inputs-compact {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

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

.form-group-compact .form-label-compact {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.form-group-compact .form-input {
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
  text-align: right;
}

/* Checkboxes Options checklist */
.options-checklist {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.option-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: var(--transition);
  color: var(--text);
}

.option-checkbox-label:hover {
  background-color: var(--surface-hover);
}

.option-checkbox-input {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.option-price-tag {
  margin-left: auto;
  font-weight: 700;
  color: var(--accent);
}

/* Giant result card for cash mode */
.giant-rolling-badge {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(5, 150, 105, 0.08));
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.giant-lbl {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--secondary);
  letter-spacing: 0.05em;
}

.giant-val {
  font-size: 2rem;
  font-weight: 900;
  color: var(--secondary);
}

.giant-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Installment visual progress bar */
.loan-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.loan-progress-bar {
  height: 10px;
  border-radius: 5px;
  background-color: var(--border);
  overflow: hidden;
  display: flex;
}

.progress-segment {
  height: 100%;
}

.segment-upfront {
  background: var(--secondary);
}

.segment-loan {
  background: var(--primary);
}

.progress-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.legend-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
}

.dot-upfront { background: var(--secondary); }
.dot-loan { background: var(--primary); }

/* Bank KPI layout */
.bank-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.bank-kpi-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.6rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.kpi-lbl {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

.kpi-val {
  font-size: 0.95rem;
  font-weight: 800;
}

.val-primary { color: var(--primary); }
.val-secondary { color: var(--secondary); }
.val-accent { color: var(--accent); }

/* Slider */
.input-slider-container {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.input-slider {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  -webkit-appearance: none;
}

.input-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}

/* Amortization schedule table */
.table-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table-scroll {
  max-height: 220px;
  overflow-y: auto;
  overflow-x: auto;
}

.pricing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.pricing-table th, .pricing-table td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.pricing-table th {
  background-color: var(--surface-hover);
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 0.7rem;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.pricing-table .num-col {
  text-align: right;
  font-weight: 600;
}

.pricing-table .label-cell {
  font-weight: 600;
}

.pricing-table .total-row td {
  background-color: rgba(16, 185, 129, 0.04);
  font-weight: 800;
  color: var(--secondary);
}

.pricing-table .header-row td {
  background-color: rgba(255, 255, 255, 0.01);
  font-weight: 700;
  color: var(--text);
  font-size: 0.8rem;
  text-transform: uppercase;
}

/* History List style */
.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}

.history-card {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  cursor: pointer;
  transition: var(--transition);
}

.history-card:hover {
  border-color: var(--primary);
  background: var(--surface-hover);
}

.history-card-header {
  display: flex;
  justify-content: space-between;
}

.history-card-title {
  font-size: 0.85rem;
  font-weight: 700;
}

.history-card-date {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.history-card-body {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.history-card-footer {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  padding-top: 0.4rem;
}

/* Button UI */
.btn {
  padding: 0.55rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text);
}

.btn-ghost:hover {
  background-color: var(--surface-hover);
}

.btn-danger {
  background-color: transparent;
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background-color: rgba(239, 68, 68, 0.05);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffffff;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-xl);
  display: none;
  z-index: 9999;
}

/* Car Preview Card */
.car-preview-card {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  overflow: hidden;
  position: relative;
  transition: var(--transition);
}
.car-preview-card img {
  max-width: 100%;
  height: 140px;
  object-fit: contain;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 1;
  transform: scale(1);
}
.car-preview-card img.fade-out {
  opacity: 0;
  transform: scale(0.95);
}
.color-dots-row {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}
.color-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.color-dot.active {
  border-color: var(--primary);
  transform: scale(1.25);
  box-shadow: 0 0 8px rgba(37, 99, 235, 0.5);
}
.color-dot:hover:not(.active) {
  transform: scale(1.15);
}
.car-preview-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Table embedded input form controls */
.table-input-wrapper {
  position: relative;
  width: 130px;
  margin-left: auto;
}
.table-form-input {
  padding: 0.25rem 0.5rem !important;
  padding-right: 1.5rem !important;
  font-size: 0.8rem !important;
  border-radius: var(--radius-sm) !important;
  background-color: rgba(255, 255, 255, 0.03) !important;
  text-align: right !important;
  height: 28px !important;
  width: 100% !important;
}
[data-theme="light"] .table-form-input {
  background-color: rgba(0, 0, 0, 0.03) !important;
}
.table-form-input:focus {
  background-color: var(--surface-hover) !important;
  border-color: var(--border-focus) !important;
}
.table-input-wrapper .input-suffix {
  right: 0.5rem !important;
  font-size: 0.75rem !important;
}

.table-inline-input-wrap {
  display: inline-flex;
  align-items: center;
  position: relative;
  width: 55px;
  margin-left: 0.5rem;
}
.table-small-input {
  padding: 0.25rem 0.5rem !important;
  padding-right: 1.25rem !important;
  font-size: 0.75rem !important;
  border-radius: var(--radius-sm) !important;
  background-color: rgba(255, 255, 255, 0.03) !important;
  text-align: right !important;
  height: 24px !important;
  width: 100% !important;
}
[data-theme="light"] .table-small-input {
  background-color: rgba(0, 0, 0, 0.03) !important;
}
.table-small-input:focus {
  background-color: var(--surface-hover) !important;
  border-color: var(--border-focus) !important;
}
.table-inline-input-wrap .input-suffix {
  right: 0.4rem !important;
  font-size: 0.7rem !important;
}

.table-small-select {
  padding: 0.15rem 1.25rem 0.15rem 0.4rem !important;
  font-size: 0.75rem !important;
  font-weight: 700 !important;
  border-radius: var(--radius-sm) !important;
  background-color: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  margin-left: 0.5rem !important;
  cursor: pointer !important;
  outline: none !important;
  font-family: var(--font) !important;
  height: 24px !important;
}
.table-small-select option {
  background-color: var(--surface) !important;
  color: var(--text) !important;
}

.read-only-val {
  font-weight: 700;
  color: var(--accent);
  text-align: right;
  padding-right: 0.9rem !important;
}

/* Print */
@media print {
  body { background: white; color: black; }
  header, .theme-toggle, .btn, .history-panel, .input-slider-container, .mode-switcher, .grid-inputs-compact, .form-input, .form-select, .car-preview-card { display: none !important; }
  .view-body { grid-template-columns: 1fr !important; }
  .table-scroll { max-height: none !important; overflow: visible !important; }
}

/* Modal styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 17, 30, 0.85);
  backdrop-filter: blur(12px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}
.modal-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-overlay.active .modal-container {
  transform: scale(1) translateY(0);
}
.modal-close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
  z-index: 10;
}
.modal-close:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-car-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
}
.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
}
.modal-viewer {
  height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-md);
  padding: 1rem;
  overflow: hidden;
}
.modal-viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  padding-bottom: 0.5rem;
}
.modal-tab-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.modal-tab-btn:hover {
  color: var(--text);
}
.modal-tab-btn.active {
  color: var(--primary);
}
.modal-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -0.5rem;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary);
  border-radius: 1px;
}
.modal-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.75rem;
  max-height: 140px;
  overflow-y: auto;
  padding: 0.25rem;
}
/* Gallery Items */
.gallery-item {
  aspect-ratio: 4/3;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  background: rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gallery-item:hover {
  border-color: var(--text-secondary);
}
.gallery-item.active {
  border-color: var(--primary);
  box-shadow: 0 0 6px rgba(37, 99, 235, 0.4);
}
/* Color Dot in gallery */
.gallery-color-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  margin: auto;
}
.gallery-color-dot.active {
  border-color: var(--primary);
  transform: scale(1.15);
  box-shadow: 0 0 8px rgba(37, 99, 235, 0.5);
}

/* Hover effect on main car preview img */
.car-preview-img {
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), filter 0.25s ease !important;
}
.car-preview-img:hover {
  transform: scale(1.05) !important;
  filter: brightness(1.05);
}

/* Schedule Modal table & summary layout */
.schedule-modal-table th, 
.schedule-modal-table td {
  padding: 0.75rem 1rem !important;
}

.modal-summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}
@media (max-width: 768px) {
  .modal-summary-row {
    grid-template-columns: repeat(2, 1fr);
  }
}
.modal-summary-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.modal-summary-card .lbl {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.modal-summary-card .val {
  font-size: 1.05rem;
  font-weight: 800;
}

/* Editable indicator styling for showroom name & phone banner */
[contenteditable="true"] {
  outline: none;
  border-radius: var(--radius-sm);
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
  padding: 0 4px;
}
[contenteditable="true"]:hover {
  background: rgba(255, 255, 255, 0.05);
  cursor: text;
}
[contenteditable="true"]:focus {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 1px var(--border-focus);
}
[data-theme="light"] [contenteditable="true"]:hover {
  background: rgba(0, 0, 0, 0.03);
}
[data-theme="light"] [contenteditable="true"]:focus {
  background: rgba(0, 0, 0, 0.05);
}

/* Mobile-first safety rails */
html,
body {
  width: 100%;
  overflow-x: hidden;
}

img,
svg,
canvas {
  max-width: 100%;
}

.calculator-container,
.panel,
.view-section,
.view-body,
.setup-form,
.result-details,
.form-group,
.table-container {
  min-width: 0;
}

@media (max-width: 640px) {
  header {
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }

  .header-left {
    min-width: 0;
    gap: 0.65rem;
  }

  .logo {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: var(--radius-sm);
  }

  .header-title {
    min-width: 0;
  }

  .header-title h1 {
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-title p {
    display: none;
  }

  .theme-toggle {
    width: 34px;
    height: 34px;
  }

  main {
    width: 100%;
    max-width: none;
    padding: 0.75rem;
  }

  .mode-switcher {
    width: 100%;
    margin-bottom: 0.75rem;
    border-radius: 12px;
  }

  .switcher-btn {
    min-width: 0;
    padding: 0.7rem 0.45rem;
    font-size: clamp(0.72rem, 3.2vw, 0.86rem);
    line-height: 1.2;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
    gap: 0.3rem;
  }

  .panel {
    width: 100%;
    padding: 1rem;
    border-radius: 14px;
  }

  .view-section {
    gap: 1rem;
  }

  .view-header {
    align-items: stretch;
    gap: 0.85rem;
  }

  .view-title {
    width: 100%;
    font-size: clamp(1rem, 5vw, 1.28rem);
    line-height: 1.25;
  }

  .action-buttons {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100%;
    gap: 0.45rem;
  }

  .btn {
    min-width: 0;
    min-height: 54px;
    padding: 0.5rem 0.25rem;
    border-radius: 10px;
    font-size: clamp(0.68rem, 3vw, 0.78rem);
    line-height: 1.2;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .view-body,
  .form-row,
  .grid-inputs-compact,
  .bank-kpi-row {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .setup-form,
  .result-details {
    gap: 1rem;
  }

  .form-label {
    font-size: 0.78rem;
  }

  .form-input,
  .form-select {
    min-height: 46px;
    padding: 0.7rem 0.85rem;
    padding-right: 2rem;
    font-size: 0.92rem;
  }

  .option-checkbox-label {
    align-items: flex-start;
    flex-wrap: wrap;
    row-gap: 0.35rem;
  }

  .option-price-tag {
    margin-left: auto;
    white-space: nowrap;
  }

  .giant-rolling-badge {
    padding: 1rem 0.75rem;
  }

  .giant-val,
  .contact-phone {
    font-size: clamp(1.35rem, 7vw, 2rem);
    overflow-wrap: anywhere;
  }

  .table-contact-banner .contact-name {
    font-size: 0.68rem;
  }

  .table-container {
    width: 100%;
  }

  .pricing-table {
    table-layout: fixed;
    font-size: 0.78rem;
  }

  .pricing-table th,
  .pricing-table td {
    padding: 0.62rem 0.45rem;
    white-space: normal;
    overflow-wrap: anywhere;
    vertical-align: middle;
  }

  .pricing-table .num-col {
    width: 44%;
  }

  .pricing-table .label-cell {
    line-height: 1.25;
  }

  .table-input-wrapper {
    width: min(118px, 100%);
  }

  .table-form-input {
    height: 32px !important;
    font-size: 0.78rem !important;
  }

  .table-inline-input-wrap {
    width: 46px;
    margin-left: 0.25rem;
  }

  .read-only-val {
    padding-right: 0.45rem !important;
  }

  .table-scroll {
    max-height: 260px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-scroll .pricing-table,
  .schedule-modal-table {
    min-width: 620px;
    table-layout: auto;
  }

  .table-scroll .pricing-table th,
  .table-scroll .pricing-table td,
  .schedule-modal-table th,
  .schedule-modal-table td {
    white-space: nowrap;
  }

  .progress-legend {
    flex-direction: column;
    gap: 0.25rem;
  }

  .history-list {
    grid-template-columns: 1fr;
  }

  .toast {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 1rem;
    text-align: center;
  }

  .modal-overlay {
    padding: 0.75rem;
    overflow: hidden;
  }

  .modal-container {
    width: 100% !important;
    max-width: none;
    max-height: calc(100dvh - 1.5rem);
    border-radius: 14px;
  }

  .modal-header {
    padding: 1rem 3rem 0.9rem 1rem;
  }

  .modal-car-title {
    font-size: 1rem;
    line-height: 1.25;
  }

  .modal-body {
    padding: 1rem;
    gap: 1rem;
  }

  .modal-viewer {
    height: min(58vw, 240px);
    padding: 0.75rem;
  }

  .modal-tabs {
    gap: 0.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-tab-btn {
    flex: 0 0 auto;
    padding: 0.55rem 0.65rem;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .modal-gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: 180px;
  }

  .modal-summary-row {
    grid-template-columns: 1fr;
  }

  .modal-body .table-container {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 380px) {
  main {
    padding: 0.55rem;
  }

  .panel {
    padding: 0.8rem;
  }

  .action-buttons {
    gap: 0.35rem;
  }

  .btn {
    min-height: 50px;
    font-size: 0.66rem;
  }

  .pricing-table {
    font-size: 0.74rem;
  }

  .table-input-wrapper {
    width: min(106px, 100%);
  }

  .table-inline-input-wrap {
    width: 42px;
  }
}

/* Phone-only app layout: prioritize clean selling workflow over desktop parity */
@media (max-width: 640px) {
  body {
    background: var(--surface);
  }

  header {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 52px;
    padding: 0.55rem 0.75rem;
  }

  .header-title h1 {
    font-size: 0.85rem;
  }

  main {
    padding: 0;
  }

  .calculator-container {
    gap: 0;
  }

  .mode-switcher {
    position: sticky;
    top: 52px;
    z-index: 25;
    margin: 0;
    padding: 0.35rem;
    border-width: 0 0 1px 0;
    border-radius: 0;
    box-shadow: none;
  }

  .switcher-btn {
    min-height: 46px;
    padding: 0.55rem 0.4rem;
    border-radius: 9px;
    font-size: 0.76rem;
    font-weight: 800;
  }

  .panel {
    border-width: 0 0 1px 0;
    border-radius: 0;
    padding: 0.85rem 0.75rem 1rem;
    box-shadow: none;
  }

  .history-panel {
    margin-top: 0 !important;
  }

  .view-header {
    padding-bottom: 0.65rem;
    gap: 0.65rem;
  }

  .view-title {
    font-size: 1.05rem;
    line-height: 1.28;
  }

  .action-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .action-buttons button[onclick="downloadQuoteImages()"] {
    display: none !important;
  }

  .btn {
    min-height: 42px;
    padding: 0.48rem 0.55rem;
    border-radius: 9px;
    font-size: 0.76rem;
    font-weight: 800;
    gap: 0.25rem;
  }

  .view-body {
    gap: 0.9rem;
  }

  .setup-form,
  .result-details {
    gap: 0.9rem;
  }

  .form-group {
    gap: 0.35rem;
  }

  .form-label {
    font-size: 0.76rem;
  }

  .form-input,
  .form-select {
    min-height: 44px;
    border-radius: 10px;
    font-size: 0.9rem;
  }

  .options-checklist {
    padding: 0.35rem;
  }

  .option-checkbox-label {
    padding: 0.5rem;
    font-size: 0.86rem;
  }

  .option-checkbox-input {
    width: 18px;
    height: 18px;
  }

  .giant-rolling-badge,
  .table-contact-banner,
  .car-preview-card,
  .bank-kpi-card {
    border-radius: 10px;
  }

  .giant-val {
    font-size: clamp(1.35rem, 6vw, 1.75rem);
  }

  .giant-sub {
    font-size: 0.76rem;
  }

  .bank-kpi-card {
    padding: 0.7rem;
  }

  .kpi-lbl {
    font-size: 0.62rem;
  }

  .kpi-val {
    font-size: 0.98rem;
  }

  .pricing-table {
    font-size: 0.76rem;
  }

  .pricing-table th,
  .pricing-table td {
    padding: 0.58rem 0.42rem !important;
  }

  .pricing-table th.num-col,
  .pricing-table td.num-col {
    padding-right: 0.42rem !important;
  }

  .pricing-table .num-col {
    width: 48%;
  }

  .table-input-wrapper {
    width: 100%;
    max-width: 120px;
  }

  .table-form-input {
    height: 34px !important;
    font-size: 0.78rem !important;
  }

  .table-inline-input-wrap {
    width: 48px;
  }

  .table-small-input {
    height: 26px !important;
    font-size: 0.72rem !important;
  }

  .read-only-val {
    font-size: 0.82rem;
  }

  .car-preview-card {
    padding: 0.75rem;
    margin-top: 0 !important;
  }

  .car-preview-card img {
    height: 118px;
  }

  .color-dot {
    width: 20px;
    height: 20px;
  }

  .table-scroll .pricing-table,
  .schedule-modal-table {
    min-width: 580px;
  }
}

@media (max-width: 360px) {
  .switcher-btn {
    font-size: 0.7rem;
  }

  .panel {
    padding-left: 0.6rem;
    padding-right: 0.6rem;
  }

  .btn {
    font-size: 0.72rem;
  }

  .pricing-table {
    font-size: 0.72rem;
  }

  .table-input-wrapper {
    max-width: 108px;
  }
}
