:root {
  color-scheme: light;
  --ink: #132019;
  --muted: #66726b;
  --line: #d7ded9;
  --canvas: #eef2ef;
  --green: #176a42;
  --green-dark: #0e4b2e;
  --red: #e60000;
  --shadow: 0 18px 46px rgba(22, 55, 38, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button, input, textarea { font: inherit; }

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 48px;
}

.control-panel {
  position: sticky;
  top: 14px;
  z-index: 10;
  padding: 22px;
  border: 1px solid #cbd6cf;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.panel-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

h1 {
  margin: 0 0 5px;
  color: var(--green-dark);
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: -0.035em;
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.status-pill {
  flex: none;
  padding: 8px 11px;
  border-radius: 999px;
  background: #e7f4ec;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
}

.ticket-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr)) minmax(210px, 1.7fr);
  gap: 14px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
  color: #26352d;
  font-size: 14px;
  font-weight: 700;
}

input, textarea {
  width: 100%;
  border: 1px solid #bdc9c1;
  border-radius: 10px;
  background: #fbfdfb;
  color: #15231b;
  outline: none;
  padding: 11px 12px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input { min-height: 44px; }
textarea { min-height: 44px; max-height: 96px; resize: vertical; }
input:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 106, 66, 0.14); }

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  padding: 11px 17px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 120ms ease, filter 120ms ease;
}

.button:hover { filter: brightness(0.96); }
.button:active { transform: translateY(1px); }
.primary { background: var(--green); color: #fff; }
.secondary { background: #e9eeeb; color: #203128; }

.summary {
  margin-left: auto;
  color: var(--muted);
  font-size: 14px;
}

.error {
  min-height: 20px;
  margin: 10px 0 0;
  color: #a51d1d;
  font-size: 14px;
  font-weight: 700;
}

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: #536159;
  font-size: 13px;
  line-height: 1.35;
}

.step strong {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-right: 5px;
  border-radius: 50%;
  background: #e7f4ec;
  color: var(--green-dark);
}

.preview-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 28px 0 12px;
}

.preview-heading h2 { margin: 0; color: #22342a; font-size: 20px; }
.preview-heading p { margin: 0; color: var(--muted); font-size: 13px; }

#pages {
  display: grid;
  gap: 24px;
  justify-items: center;
}

.print-page {
  width: 8.5in;
  height: 11in;
  padding: 0.12in 0.25in;
  overflow: hidden;
  background: #fff;
  display: grid;
  grid-template-columns: repeat(2, 3.9in);
  grid-template-rows: repeat(4, 2.508in);
  column-gap: 0.15in;
  row-gap: 0.16in;
  box-shadow: 0 16px 40px rgba(25, 45, 34, 0.16);
}

.ticket {
  position: relative;
  overflow: hidden;
  border: 2px solid #111;
  background: #fff;
  color: #050505;
  font-family: Cambria, Georgia, "Times New Roman", serif;
}

.ticket-logo {
  position: absolute;
  left: 3.2%;
  top: 7.5%;
  width: 15.8%;
  height: auto;
}

.ticket-title {
  position: absolute;
  left: 22.5%;
  right: 3.5%;
  top: 7.3%;
  text-align: center;
  font-size: 9.4pt;
  line-height: 1.16;
  white-space: nowrap;
}

.ticket-title strong {
  display: block;
  margin-top: 5px;
  font-size: 10.7pt;
}

.serie-label {
  position: absolute;
  left: 41.6%;
  top: 27.6%;
  font-size: 10.8pt;
}

.serie-number {
  position: absolute;
  left: 70.2%;
  top: 26.6%;
  color: var(--red);
  font-size: 13.4pt;
  white-space: nowrap;
}

.species-label {
  position: absolute;
  left: 6.5%;
  top: 42.1%;
  font-size: 11pt;
}

.ticket-value {
  position: absolute;
  left: 75.4%;
  top: 40.6%;
  font-size: 13.3pt;
  white-space: nowrap;
}

.concept-label {
  position: absolute;
  left: 6.3%;
  top: 54.2%;
  font-size: 10pt;
}

.concept-value {
  position: absolute;
  left: 35.7%;
  right: 2.5%;
  top: 50.6%;
  font-size: 9.5pt;
  line-height: 1.65;
}

.signatures {
  position: absolute;
  left: 12.4%;
  right: 9.2%;
  top: 84.6%;
  display: grid;
  grid-template-columns: 1fr 1.18fr;
  gap: 16%;
}

.signature { text-align: center; font-size: 10.2pt; }
.signature::before { content: ""; display: block; border-top: 1px solid #000; margin-bottom: 3px; }

.designation {
  position: absolute;
  right: 1.8%;
  bottom: 1.1%;
  color: var(--red);
  font-size: 7.2pt;
}

.empty-slot { border: 0; }

@media (max-width: 980px) {
  .ticket-form { grid-template-columns: repeat(2, 1fr); }
  .steps { grid-template-columns: repeat(2, 1fr); }
  .print-page { transform-origin: top center; zoom: 0.75; }
  #pages { gap: 0; }
}

@media (max-width: 700px) {
  .app-shell { width: min(100% - 18px, 1180px); margin-top: 10px; }
  .control-panel { position: static; padding: 16px; border-radius: 14px; }
  .panel-top { display: block; }
  .status-pill { display: inline-block; margin-top: 10px; }
  .ticket-form, .steps { grid-template-columns: 1fr; }
  .summary { width: 100%; margin-left: 0; }
  .print-page { zoom: 0.46; }
}

@page { size: letter portrait; margin: 0; }

@media print {
  body { background: #fff; }
  .control-panel, .preview-heading { display: none !important; }
  .app-shell { width: auto; margin: 0; }
  #pages { display: block; }
  .print-page {
    width: 8.5in;
    height: 11in;
    margin: 0;
    box-shadow: none;
    break-after: page;
    page-break-after: always;
    zoom: 1;
  }
  .print-page:last-child { break-after: auto; page-break-after: auto; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
