:root {
  --cdf-red: #c00000;
  --cdf-red-dark: #8f0000;
  --cdf-black: #1a1a1a;
  --cdf-gray-dark: #3f3f3f;
  --cdf-gray: #6b6b6b;
  --cdf-gray-light: #e9e9e9;
  --cdf-bg: #f5f5f5;
  --cdf-white: #ffffff;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cdf-bg);
  color: var(--cdf-black);
  font-family: 'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body { padding-bottom: 24px; }

button, input, select { font-family: inherit; }

.app-shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- Header / Logo ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0 14px;
}

.cdf-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cdf-logo-mark {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2.5px solid var(--cdf-black);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Baloo 2', 'Poppins', sans-serif;
  font-weight: 800;
  font-size: 22px;
  color: var(--cdf-black);
  background: var(--cdf-white);
  flex-shrink: 0;
}

.cdf-logo-text {
  line-height: 1.1;
}

.cdf-logo-text .cdf-name {
  font-family: 'Baloo 2', 'Poppins', sans-serif;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.5px;
}

.cdf-logo-text .cdf-tagline {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--cdf-gray);
  text-transform: uppercase;
}

.app-title-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--cdf-gray);
  background: var(--cdf-gray-light);
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- Steps indicator ---------- */
.steps {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.step {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--cdf-gray-light);
  transition: background 0.25s ease;
}

.step.active, .step.done { background: var(--cdf-red); }

/* ---------- Cards / sections ---------- */
.card {
  background: var(--cdf-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 700;
}

.card .subtitle {
  margin: 0 0 18px;
  color: var(--cdf-gray);
  font-size: 13.5px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--cdf-gray-dark);
}

.field .hint {
  font-size: 12px;
  color: var(--cdf-gray);
  margin-top: 5px;
}

input[type="text"],
input[type="date"],
input[type="number"],
select,
textarea,
.combo-input {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--cdf-gray-light);
  border-radius: 10px;
  font-size: 15.5px;
  background: var(--cdf-white);
  color: var(--cdf-black);
  outline: none;
  transition: border-color 0.15s ease;
  min-height: 48px;
}

textarea {
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}

input:focus, select:focus, textarea:focus, .combo-input:focus {
  border-color: var(--cdf-red);
}

.field-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.field-row .field { flex: 1 1 200px; }

/* ---------- Combobox / city autocomplete ---------- */
.combo {
  position: relative;
}

.combo-list {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--cdf-white);
  border: 1.5px solid var(--cdf-gray-light);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  max-height: 240px;
  overflow-y: auto;
  display: none;
}

.combo-list.open { display: block; }

.combo-option {
  padding: 12px 14px;
  font-size: 15px;
  cursor: pointer;
}

.combo-option:hover,
.combo-option.highlight {
  background: #fbeaea;
  color: var(--cdf-red-dark);
}

.combo-empty {
  padding: 12px 14px;
  font-size: 14px;
  color: var(--cdf-gray);
}

/* ---------- Type toggle (Cliente / Distribuidor) ---------- */
.toggle-group {
  display: flex;
  gap: 10px;
}

.toggle-btn {
  flex: 1;
  padding: 13px 10px;
  border: 1.5px solid var(--cdf-gray-light);
  border-radius: 10px;
  background: var(--cdf-white);
  font-weight: 600;
  font-size: 14.5px;
  color: var(--cdf-gray-dark);
  cursor: pointer;
  min-height: 48px;
  transition: all 0.15s ease;
}

.toggle-btn.selected {
  border-color: var(--cdf-red);
  background: var(--cdf-red);
  color: var(--cdf-white);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 15px 22px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 15.5px;
  border: none;
  cursor: pointer;
  min-height: 50px;
  width: 100%;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--cdf-red); color: var(--cdf-white); }
.btn-primary:hover { background: var(--cdf-red-dark); }

.btn-dark { background: var(--cdf-black); color: var(--cdf-white); }

.btn-outline {
  background: var(--cdf-white);
  color: var(--cdf-black);
  border: 1.5px solid var(--cdf-black);
}

.btn-ghost {
  background: transparent;
  color: var(--cdf-gray-dark);
  border: 1.5px solid var(--cdf-gray-light);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-row .btn { flex: 1 1 160px; }

/* ---------- Error banner ---------- */
.error-banner {
  background: #fdeaea;
  border: 1.5px solid var(--cdf-red);
  color: var(--cdf-red-dark);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
  display: none;
}

.error-banner.show { display: block; }

/* ---------- Sticky totals bar (screen 2) ---------- */
.sticky-totals {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--cdf-black);
  color: var(--cdf-white);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.sticky-totals .label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #c9c9c9;
}

.sticky-totals .value {
  font-size: 22px;
  font-weight: 800;
  color: var(--cdf-white);
}

.sticky-totals .count {
  font-size: 12.5px;
  color: #c9c9c9;
}

/* ---------- Buscador de productos ---------- */
.search-wrap {
  margin-bottom: 14px;
}

.search-wrap .combo-input {
  padding-left: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 18px 18px;
}

.no-results {
  display: none;
  text-align: center;
  padding: 30px 16px;
  color: var(--cdf-gray);
  font-size: 14.5px;
  background: var(--cdf-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.no-results.show { display: block; }

/* ---------- Category sections ---------- */
.category {
  margin-bottom: 20px;
}

.category-header {
  background: var(--cdf-red);
  color: var(--cdf-white);
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14.5px;
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}

/* Desktop table */
.product-table {
  width: 100%;
  border-collapse: collapse;
  display: none;
}

.product-table th {
  background: var(--cdf-black);
  color: var(--cdf-white);
  text-align: left;
  padding: 10px 12px;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.product-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--cdf-gray-light);
  font-size: 14.5px;
  vertical-align: middle;
}

.product-table tr:last-child td { border-bottom: none; }
.product-table tr.selected-row { background: #fdf3f3; }

/* Mobile product cards */
.product-card {
  background: var(--cdf-white);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 10px;
  border: 1.5px solid transparent;
}

.product-card.selected-row {
  border-color: var(--cdf-red);
  background: #fdf3f3;
}

.product-card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.product-checkbox {
  width: 24px;
  height: 24px;
  accent-color: var(--cdf-red);
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
}

.product-info { flex: 1; }

.product-name {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 2px;
}

.product-pres {
  font-size: 13px;
  color: var(--cdf-gray);
}

.product-note {
  display: inline-block;
  margin-top: 5px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--cdf-red-dark);
  background: #fdeaea;
  padding: 3px 8px;
  border-radius: 999px;
}

.product-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.qty-input, .manual-price-input {
  width: 90px;
  padding: 10px;
  min-height: 42px;
  border: 1.5px solid var(--cdf-gray-light);
  border-radius: 8px;
  font-size: 15px;
  text-align: center;
}

.manual-price-input { width: 130px; text-align: right; }

.manual-price-input::placeholder {
  font-size: 12px;
  color: var(--cdf-gray);
}

.qty-wrap, .price-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.qty-wrap label, .price-wrap label {
  font-size: 11px;
  color: var(--cdf-gray);
  font-weight: 600;
  text-transform: uppercase;
}

.line-subtotal {
  margin-left: auto;
  font-weight: 800;
  font-size: 16px;
  color: var(--cdf-black);
}

.line-subtotal.zero { color: var(--cdf-gray); }

.unit-price-static {
  font-weight: 700;
  font-size: 15px;
}

@media (min-width: 760px) {
  .product-table { display: table; }
  .product-card { display: none; }
}

/* ---------- Quote preview (screen 3) ---------- */
.quote-doc {
  background: var(--cdf-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  margin-bottom: 18px;
}

.quote-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 3px solid var(--cdf-black);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.quote-title-box {
  border: 2px solid var(--cdf-black);
  border-radius: 8px;
  padding: 10px 26px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 1px;
  text-align: center;
}

.quote-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 24px;
  margin-bottom: 18px;
  font-size: 14px;
}

.quote-meta .k { color: var(--cdf-gray); font-weight: 600; }
.quote-meta .v { font-weight: 700; }

.quote-intro {
  font-size: 13.5px;
  color: var(--cdf-gray-dark);
  line-height: 1.5;
  margin-bottom: 18px;
}

.quote-table-wrap {
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
  border: 1px solid var(--cdf-gray-light);
}

table.quote-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.quote-table th {
  background: var(--cdf-red);
  color: var(--cdf-white);
  padding: 9px 10px;
  text-align: left;
}

table.quote-table th.num, table.quote-table td.num { text-align: right; }

table.quote-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--cdf-gray-light);
}

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

.quote-totals {
  margin-left: auto;
  width: 100%;
  max-width: 320px;
  font-size: 14px;
}

.quote-totals .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--cdf-gray-light);
}

.quote-totals .row.total {
  border-bottom: none;
  border-top: 2px solid var(--cdf-black);
  font-weight: 800;
  font-size: 17px;
  padding-top: 10px;
  margin-top: 4px;
  color: var(--cdf-red-dark);
}

.quote-obs {
  margin-top: 20px;
  font-size: 12.5px;
  color: var(--cdf-gray-dark);
  background: var(--cdf-gray-light);
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.6;
}

.quote-signature {
  margin-top: 26px;
  font-size: 14px;
  line-height: 1.7;
}

.quote-footer-brand {
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid var(--cdf-gray-light);
  text-align: center;
  font-size: 11.5px;
  color: var(--cdf-gray);
}

.quote-number {
  font-size: 12px;
  color: var(--cdf-gray);
  margin-top: 4px;
}

/* ---------- Utility ---------- */
.screen { display: none; }
.screen.active { display: block; }

.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.spacer { height: 8px; }

@media (max-width: 480px) {
  .quote-title-box { font-size: 15px; padding: 8px 16px; }
  .quote-meta { grid-template-columns: 1fr; }
}
