:root {
  --terra: #af5a38;
  --terra-dark: #8c4529;
  --gold: #d9bf75;
  --cream: #f0e8d6;
  --sand: #f5efe3;
  --ink: #141210;
  --muted: #5a514a;
  --line: #e4d9c8;
  --paper: #fffdf9;
  --wa: #14643f;
  --display: "Cormorant Garamond", Georgia, serif;
  --sans: "Outfit", "Segoe UI", sans-serif;
  --shadow: 0 12px 32px rgba(20, 18, 16, 0.06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { background: var(--terra); }
body {
  margin: 0;
  background: var(--sand);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.45;
  min-height: 100dvh;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
h2, p { margin: 0; }
:focus-visible { outline: 2px solid var(--terra); outline-offset: 2px; }

.mark { width: 36px; height: auto; color: #f3e6d4; display: block; }

#boot {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background: var(--terra);
  color: #fff8ee;
  text-align: center;
  padding: 32px 24px;
}
#boot[hidden], #app[hidden] { display: none; }
.boot-card { max-width: 280px; }
.boot-card .mark { width: 84px; margin: 0 auto 8px; }
.boot-card .name {
  font-weight: 700;
  letter-spacing: 0.16em;
  font-size: 18px;
}
.boot-card .name i { font-style: normal; color: var(--gold); }
.boot-card .tag {
  font-family: var(--display);
  font-style: italic;
  font-size: 20px;
  color: var(--gold);
  margin: 4px 0 18px;
}
#boot-msg { color: #fff8ee; font-size: 15px; }
#boot-retry {
  margin-top: 16px;
  background: transparent;
  color: #fff8ee;
  border: 1px solid #fff8ee;
  padding: 10px 16px;
}

.sticky-top { position: sticky; top: 0; z-index: 30; }
header.top { background: var(--terra); color: #fff8ee; }
.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.wm { display: flex; flex-direction: column; line-height: 1; min-width: 0; }
.wm .name {
  font-weight: 700;
  letter-spacing: 0.14em;
  font-size: 15px;
  color: #fff8ee;
}
.wm .name i { font-style: normal; color: var(--gold); }
.rule {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 4px 0 3px;
  width: 100%;
}
.rule::before, .rule::after {
  content: "";
  height: 1px;
  background: var(--gold);
  flex: 1;
}
.rule i {
  width: 4px;
  height: 4px;
  background: var(--gold);
  transform: rotate(45deg);
  flex: none;
}
.wm .tag {
  font-family: var(--display);
  font-style: italic;
  font-weight: 500;
  color: var(--gold);
  font-size: 14px;
  letter-spacing: 0.01em;
}
.folio-chip {
  flex: none;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-align: right;
  color: #fff8ee;
  line-height: 1.25;
}
input, textarea { scroll-margin-bottom: 150px; }
.folio-chip strong { display: block; font-weight: 600; font-size: 13px; }

.switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--sand);
  border-bottom: 1px solid var(--line);
}
.switch.switch-3 { grid-template-columns: 1fr 1fr 1fr; }
.switch button {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  min-height: 44px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 13px;
}
.switch button[aria-selected="true"] {
  color: var(--terra-dark);
  border-bottom-color: var(--terra);
}
.badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 99px;
  background: var(--terra);
  color: #fff8ee;
  font-size: 11px;
  letter-spacing: 0;
  font-weight: 600;
}

.offline {
  margin: 0;
  padding: 8px 16px;
  background: var(--ink);
  color: var(--cream);
  font-size: 13px;
}

.page { padding: 16px 16px 132px; max-width: 100%; }
.cotizar-grid { display: grid; gap: 8px; min-width: 0; }
.col-form, section { min-width: 0; max-width: 100%; }
section { margin: 0 0 22px; }
h2 {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--terra-dark);
  margin: 0 0 10px;
}

.tipos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tipos button:last-child:nth-child(odd) { grid-column: 1 / -1; }
.tipos button {
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  min-height: 74px;
  padding: 10px 12px;
}
.tipos button strong { display: block; font-size: 14px; font-weight: 600; line-height: 1.25; }
.tipos button small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.3; }
.tipos button[aria-checked="true"] {
  background: var(--terra-dark);
  border-color: var(--terra-dark);
  color: #fff8ee;
}
.tipos button[aria-checked="true"] small { color: var(--cream); }

.field { display: block; margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.field input, .field textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 12px;
  font-size: 16px;
  color: var(--ink);
}
.field textarea { min-height: 76px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--terra); }
.pair { display: grid; gap: 0 12px; }

.linea {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  min-width: 0;
  max-width: 100%;
}
.linea-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.linea-top button {
  background: transparent;
  border: 0;
  color: var(--terra-dark);
  letter-spacing: 0.04em;
  text-transform: none;
  font-size: 14px;
  padding: 6px;
}
.modelos { display: flex; flex-wrap: wrap; gap: 8px; }
.modelos button {
  flex: 1 1 calc(33% - 8px);
  min-width: 96px;
  min-height: 52px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  padding: 8px 10px;
}
.modelos button b { display: block; font-weight: 600; font-size: 14px; }
.modelos button small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.modelos button[aria-checked="true"] {
  background: var(--terra-dark);
  border-color: var(--terra-dark);
  color: #fff8ee;
}
.modelos button[aria-checked="true"] small { color: var(--cream); }
.spec {
  margin: 10px 0 8px;
  color: var(--muted);
  font-size: 12.5px;
}
.colores {
  display: flex;
  gap: 8px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 2px 2px 8px;
}
.sw {
  flex: 0 0 72px;
  scroll-snap-align: start;
  background: transparent;
  border: 0;
  padding: 2px;
}
.sw .chip {
  width: 68px;
  height: 52px;
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid rgba(20, 18, 16, 0.12);
}
.sw img { width: 100%; height: 100%; object-fit: cover; }
.sw span {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  color: var(--ink);
}
.sw[aria-checked="true"] .chip {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.sw[aria-checked="true"] span { color: var(--terra-dark); font-weight: 600; }
.metros-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  margin-top: 4px;
}
.metros-row .field { margin: 0; }
.importes { text-align: right; padding-bottom: 4px; }
.importes .pu { display: block; color: var(--muted); font-size: 12px; }
.importes .imp {
  display: block;
  font-family: var(--display);
  font-size: 28px;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
}

.add {
  width: 100%;
  min-height: 48px;
  background: transparent;
  border: 1px dashed var(--terra);
  color: var(--terra-dark);
  font-weight: 600;
}
.aviso {
  margin-top: 12px;
  background: #f8e6d4;
  border-left: 3px solid var(--terra);
  padding: 10px 12px;
  font-size: 14px;
}
.aviso strong { display: block; margin-bottom: 4px; }
.aviso ul { margin: 0; padding-left: 18px; }

.side {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 16px;
}
.eyebrow {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--terra-dark);
  font-weight: 600;
}
.folio-line { margin: 6px 0 12px; color: var(--muted); font-size: 14px; }
.totals { margin: 0; }
.totals div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-size: 15px;
}
.totals dt { color: var(--muted); }
.totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.grand {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--terra);
}
.grand span { font-weight: 600; }
.grand strong, .bar-tot strong {
  font-family: var(--display);
  font-weight: 600;
  font-size: 36px;
  line-height: 0.9;
  color: var(--terra-dark);
  font-variant-numeric: tabular-nums;
}
.vig { margin-top: 8px; color: var(--muted); font-size: 13px; }
.drift {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}
.drift button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--terra-dark);
  font-weight: 600;
  text-decoration: underline;
}
.actions { display: grid; grid-template-columns: 1fr 1fr 1.15fr; gap: 8px; margin-top: 14px; }
.btn {
  min-height: 46px;
  border: 1px solid var(--terra-dark);
  background: var(--terra-dark);
  color: #fff8ee;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
  padding: 10px 8px;
}
.btn.ghost { background: transparent; color: var(--terra-dark); }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn:disabled { opacity: 0.55; }
.text {
  display: block;
  width: 100%;
  margin-top: 8px;
  background: none;
  border: 0;
  color: var(--terra-dark);
  font-size: 14px;
  text-align: center;
  padding: 8px;
  text-decoration: underline;
}
.fine {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.side .actions { display: none; }

.bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgba(20, 18, 16, 0.06);
}
.bar-tot { display: flex; justify-content: space-between; align-items: baseline; }
.bar-tot span { color: var(--muted); font-size: 13px; }
.bar-tot strong { font-size: 32px; }
.bar-note { margin: 2px 0 0; color: var(--terra-dark); font-size: 12px; }
body.is-hist .bar, body.kb .bar { display: none; }
body.is-hist .page, body.kb .page { padding-bottom: 28px; }

#view-historial { padding-top: 4px; }
.search input { background: #fff; }
.hist-meta { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.hcard {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 14px;
  margin-bottom: 10px;
}
.hcard header { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.hcard h3 {
  margin: 4px 0 0;
  font-family: var(--display);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.1;
}
.hcard .company { color: var(--muted); font-size: 14px; }
.hcard .meta { margin-top: 6px; font-size: 13px; color: var(--ink); }
.htotal {
  margin-top: 6px;
  font-family: var(--display);
  font-size: 28px;
  color: var(--terra-dark);
  font-weight: 600;
}
.hactions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.hactions button {
  min-height: 42px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 14px;
}
.hactions button.danger { color: var(--terra-dark); }
.empty {
  text-align: center;
  padding: 28px 12px 12px;
}
.empty .mark { width: 64px; margin: 0 auto 8px; color: var(--terra); }
.empty h3 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 28px;
  margin: 0 0 6px;
}
.empty p { color: var(--muted); font-size: 15px; }
.backup { display: flex; gap: 16px; justify-content: center; margin: 8px 0 20px; }

#toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(118px + env(safe-area-inset-bottom));
  z-index: 40;
  background: var(--ink);
  color: var(--cream);
  padding: 12px 14px;
  font-size: 14px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
#toast.show { opacity: 1; transform: none; }
body.is-hist #toast, body.kb #toast { bottom: 16px; }

#modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(20, 18, 16, 0.46);
  display: grid;
  place-items: end center;
  padding: 16px;
}
#modal[hidden] { display: none; }
.modal-card {
  width: min(420px, 100%);
  background: var(--paper);
  padding: 18px 16px 16px;
  margin-bottom: env(safe-area-inset-bottom);
}
.modal-card h3 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 28px;
  font-weight: 600;
}
.modal-card p { color: var(--muted); margin-bottom: 14px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.modal-actions .danger { background: var(--terra-dark); border-color: var(--terra-dark); color: #fff8ee; }

@media (min-width: 720px) {
  .pair { grid-template-columns: 1fr 1fr; }
  .page { padding-left: 24px; padding-right: 24px; }
}

@media (min-width: 960px) {
  .page { max-width: 1080px; margin: 0 auto; padding-top: 24px; padding-bottom: 48px; }
  .cotizar-grid { grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; }
  .side { position: sticky; top: 108px; }
  .side .actions { display: grid; grid-template-columns: 1fr; }
  .phone-only { display: none; }
  .bar { display: none; }
  #toast { bottom: 24px; left: auto; right: 24px; width: min(360px, calc(100% - 48px)); }
  #modal { place-items: center; }
}

.who {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--cream);
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.who-actions { display: flex; gap: 8px; }
.who button, .estatus button {
  background: #fff;
  border: 1px solid var(--line);
  min-height: 36px;
  padding: 6px 10px;
  font-size: 13px;
}
.estatus { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 10px; }
.estatus button[aria-pressed="true"] { background: var(--terra-dark); color: #fff8ee; border-color: var(--terra-dark); }

#login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--sand);
}
#login[hidden] { display: none; }
.login-card {
  width: min(420px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 28px 18px 20px;
  text-align: center;
}
.login-card .mark { width: 64px; margin: 0 auto 8px; color: var(--terra); }
.login-card .name { font-weight: 700; letter-spacing: 0.16em; }
.login-card .name i { font-style: normal; color: var(--terra); }
.login-card .tag { font-family: var(--display); font-style: italic; color: var(--terra-dark); font-size: 22px; margin: 4px 0 16px; }
.login-card .field { text-align: left; }
.login-card select, .field select {
  display: block;
  width: 100%;
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 12px;
  font-size: 16px;
}
.login-card .btn { width: 100%; }
.login-error { min-height: 1.3em; color: var(--terra-dark); font-size: 14px; margin: 10px 0 0; }

#pin-box {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(20, 18, 16, 0.46);
  display: grid;
  place-items: end center;
  padding: 16px;
}
#pin-box[hidden] { display: none; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.kpis article { background: var(--paper); border: 1px solid var(--line); padding: 12px; }
.kpis span { display: block; color: var(--muted); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; }
.kpis strong { display: block; margin-top: 4px; font-family: var(--sans); font-size: 26px; font-weight: 600; color: var(--terra-dark); line-height: 1; }
.table-wrap { overflow-x: auto; margin-bottom: 16px; background: var(--paper); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
.pin-form { margin: 8px 0 24px; }

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