:root {
  --black: #121212;
  --black-soft: #1c1c1c;
  --red: #d41e1e;
  --red-dark: #9c1414;
  --white: #ffffff;
  --off-white: #f4f4f2;
  --line: #2a2a2a;
  --field-line: #c9c9c9;
  --text-dim: #6b6b6b;
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--off-white);
  color: var(--black);
  font-family: 'Inter', sans-serif;
  padding-bottom: 3rem;
}

/* signature speed-line accent, echoing the logo's swoosh */
.speedline {
  height: 6px;
  background: linear-gradient(90deg, var(--red-dark) 0%, var(--red) 35%, var(--red) 65%, var(--black) 100%);
}

.topbar {
  background: var(--black);
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.1rem 2rem;
  flex-wrap: wrap;
  border-bottom: 3px solid var(--red);
}

.logo {
  height: 52px;
  width: auto;
  flex-shrink: 0;
}

.brand {
  flex: 1;
  min-width: 220px;
}

.brand h1 {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: 0.04em;
  margin: 0;
  line-height: 1.1;
}

.brand .tag {
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
}

.quote-badge {
  background: var(--black-soft);
  border: 1px solid var(--red);
  border-radius: 4px;
  padding: 0.5rem 1rem;
  text-align: right;
  min-width: 190px;
}

.quote-eyebrow {
  display: block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  color: #9a9a9a;
}

.quote-number {
  display: block;
  font-family: 'Space Mono', monospace;
  font-size: 1.15rem;
  color: var(--red);
  font-weight: 700;
  letter-spacing: 0.03em;
}

.sheet {
  max-width: 760px;
  margin: 2rem auto;
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.group {
  background: var(--white);
  border: 1px solid #e2e0da;
  border-left: 4px solid var(--red);
  border-radius: 6px;
  padding: 1.5rem 1.75rem;
}

.group-title {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 1.25rem 0;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  color: var(--black);
}

.group-title .idx {
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  color: var(--red);
  font-weight: 700;
}

.field {
  display: grid;
  grid-template-columns: 150px 1fr;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid #efeeea;
}

.field:last-child {
  border-bottom: none;
}

.field label {
  font-family: 'Oswald', sans-serif;
  font-weight: 500;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--black);
}

.field input,
.field select {
  font-family: 'Inter', sans-serif;
  font-size: 0.92rem;
  border: none;
  border-bottom: 1.5px solid var(--field-line);
  background: transparent;
  padding: 0.4rem 0.1rem;
  color: var(--black);
  outline: none;
  width: 100%;
  transition: border-color 0.15s ease;
}

.field input::placeholder {
  color: #b7b5ae;
}

.field input:focus,
.field select:focus {
  border-bottom-color: var(--red);
}

.field input[readonly] {
  color: var(--text-dim);
  border-bottom-style: dashed;
}

.field select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23d41e1e' stroke-width='2' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.2rem center;
  padding-right: 1.2rem;
}

.footbar {
  text-align: center;
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2rem;
}

/* ---- Table section (Part 2) ---- */

.table-section {
  border-left-color: var(--black);
}

.tc-row {
  display: grid;
  grid-template-columns: 220px 160px;
  align-items: center;
  gap: 1rem;
  background: var(--black-soft);
  color: var(--white);
  padding: 0.7rem 1rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
}

.tc-row label {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--white);
}

.tc-row input {
  font-family: 'Space Mono', monospace;
  font-size: 0.95rem;
  border: none;
  border-bottom: 1.5px solid var(--red);
  background: transparent;
  color: var(--white);
  padding: 0.3rem 0.1rem;
  outline: none;
}

.entry-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem 1.1rem;
  align-items: end;
  padding: 1rem;
  background: var(--off-white);
  border: 1px dashed #d8d6cf;
  border-radius: 6px;
  margin-bottom: 1.5rem;
}

.entry-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1 1 160px;
  min-width: 130px;
  position: relative;
}

.entry-field.entry-narrow {
  flex: 0 1 100px;
  min-width: 90px;
}

.entry-field.entry-codigo {
  flex: 1 1 200px;
  min-width: 160px;
}

.entry-field label {
  font-family: 'Oswald', sans-serif;
  font-weight: 500;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--black);
}

.entry-field input,
.entry-field select {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  border: none;
  border-bottom: 1.5px solid var(--field-line);
  background: var(--white);
  padding: 0.4rem 0.35rem;
  color: var(--black);
  outline: none;
  width: 100%;
}

.entry-field input:focus,
.entry-field select:focus {
  border-bottom-color: var(--red);
}

.entry-field input[readonly] {
  color: var(--text-dim);
  border-bottom-style: dashed;
}

.entry-field.entry-action {
  flex: 0 0 auto;
}

.btn-guardar {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--red);
  color: var(--white);
  border: none;
  border-radius: 4px;
  padding: 0.55rem 1.3rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-guardar:hover {
  background: var(--red-dark);
}

.btn-guardar:disabled {
  background: #c9c7c0;
  cursor: not-allowed;
}

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--white);
  border: 1px solid var(--field-line);
  border-radius: 4px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
  display: none;
}

.suggestions.active {
  display: block;
}

.suggestion-item {
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  border-bottom: 1px solid #f0efec;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.highlighted {
  background: var(--off-white);
}

.suggestion-item .s-codigo {
  font-family: 'Space Mono', monospace;
  color: var(--red);
  font-weight: 700;
  margin-right: 0.4rem;
}

.table-wrap {
  overflow-x: auto;
}

#itemsTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 920px;
}

#itemsTable thead th {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--black);
  color: var(--white);
  padding: 0.55rem 0.5rem;
  text-align: left;
  white-space: nowrap;
}

#itemsTable tbody td {
  padding: 0.5rem;
  border-bottom: 1px solid #ece9e2;
  white-space: nowrap;
}

#itemsTable tbody tr:hover {
  background: #fbf7f0;
}

#itemsTable tfoot td {
  padding: 0.6rem 0.5rem;
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  border-top: 2px solid var(--black);
}

.totals-label {
  font-family: 'Oswald', sans-serif;
  text-align: right;
  color: var(--black);
  letter-spacing: 0.06em;
}

.row-actions {
  display: flex;
  gap: 0.4rem;
}

.row-actions button {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
}

.row-actions .edit-btn {
  color: #2563eb;
}

.row-actions .delete-btn {
  color: var(--red);
}

.row-actions button:hover {
  background: #f0efec;
}

.empty-row td {
  text-align: center;
  color: var(--text-dim);
  font-style: italic;
  padding: 1.2rem;
}

@media (max-width: 560px) {
  .field {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
  .topbar {
    padding: 1rem 1.25rem;
  }
  .quote-badge {
    text-align: left;
  }
  .tc-row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
  .entry-field {
    flex: 1 1 100%;
  }
}
