:root {
  --red: #CC0000;
  --red-hover: #AA0000;
  --red-soft: #FFEBEE;
  --text: #111827;
  --muted: #8C8C8C;
  --surface: #F5F5F5;
  --page: #F1FAF3;
  --border: #E0E0E0;
  --white: #FFFFFF;
  --warning-bg: #FFF8E1;
  --success: #1B5E20;
  --radius-card: 8px;
  --shadow: 0 1px 4px rgba(17, 24, 39, 0.12);

  --rec-bg: #F1F8E9;
  --rec-text: #558B2F;
  --rec-border: #DCEDC8;
  --diag-bg: #FFF3E0;
  --diag-text: #E65100;
  --diag-border: #FFE0B2;
  --rep-bg: #FFEBEE;
  --rep-text: #CC0000;
  --rep-border: #FFCDD2;
  --ready-bg: #E8F5E9;
  --ready-text: #1B5E20;
  --ready-border: #C8E6C9;
  --done-bg: #F5F5F5;
  --done-text: #616161;
  --done-border: #E0E0E0;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--page);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

button,
input {
  font: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 14px 24px;
  color: var(--white);
  background: var(--red);
}

.brand {
  text-align: center;
  line-height: 1.05;
}

.brand strong {
  display: block;
  font-size: 30px;
  font-weight: 700;
}

.brand span {
  display: block;
  margin-top: 8px;
  font-size: 18px;
  letter-spacing: 0.18em;
}

.icon-button,
.outline-top {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.icon-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.header-back {
  position: absolute;
  left: 18px;
  display: none;
}

.outline-top {
  position: absolute;
  right: 24px;
  display: none;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 4px;
  font-weight: 700;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 96px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero {
  max-width: 420px;
  margin: 0 auto 24px;
  text-align: center;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 500;
}

.hero p {
  margin: 0;
  color: #555555;
  font-size: 18px;
  line-height: 1.35;
}

.query-form {
  max-width: 420px;
  margin: 0 auto;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field span {
  display: block;
  margin-bottom: 4px;
  color: #7D7D7D;
}

.field input {
  width: 100%;
  min-height: 56px;
  padding: 0 22px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
  outline: none;
}

.field input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(204, 0, 0, 0.08);
}

.field input.error {
  border-color: #B71C1C;
}

.field small {
  display: none;
  margin-top: 6px;
  color: #B71C1C;
}

.field small.visible {
  display: block;
}

.primary-button {
  width: 100%;
  min-height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 8px;
  background: var(--red);
  color: var(--white);
  font-weight: 700;
  cursor: pointer;
}

.primary-button:hover {
  background: var(--red-hover);
}

.primary-button:disabled {
  cursor: wait;
  background: #9E9E9E;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.section-heading {
  max-width: 980px;
  margin: 14px auto 30px;
}

.section-heading h1 {
  margin: 0 0 12px;
  font-size: 24px;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
}

/* ── Resultados: cards mobile ── */
.result-grid {
  max-width: 980px;
  margin: 0 auto 42px;
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 26px;
}

.ticket-result {
  min-height: 112px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--white);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.ticket-result:hover {
  border-color: #BDBDBD;
}

.ticket-result header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.ticket-result h2 {
  margin: 0;
  font-size: 17px;
}

.ticket-result p {
  margin: 0 0 18px;
  line-height: 1.55;
}

.ticket-result a,
.ticket-result .action-copy {
  color: var(--red);
  font-weight: 500;
}

.ticket-result .meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

.ticket-result .meta-equipo {
  font-size: 13px;
  color: var(--text);
  margin: 0 0 8px;
}

.ticket-result .meta-equipo span {
  font-weight: 700;
}

/* ── Resultados: tabla desktop (HSPP90) ── */
.results-table-wrap {
  display: none;
  max-width: 980px;
  margin: 0 auto 42px;
  overflow-x: auto;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #EDEDED;
  border-radius: var(--radius-card);
  background: var(--white);
  overflow: hidden;
}

.results-table thead tr {
  background: #F5FBF5;
  border-bottom: 1px solid #EDEDED;
}

.results-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.results-table tbody tr {
  border-bottom: 1px solid #EDEDED;
  transition: background 0.15s;
  cursor: pointer;
}

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

.results-table tbody tr:hover {
  background: #F5FBF5;
}

.results-table td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  vertical-align: middle;
}

.results-table td.col-ticket {
  font-weight: 700;
}

.results-table td.col-details {
  font-size: 11px;
  color: var(--muted);
}

.detail-parts {
  color: #E65100;
}

.detail-quality {
  color: var(--success);
}

/* ── Badges de garantía ── */
.warranty-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid;
  white-space: nowrap;
}

.warranty-activa {
  background: #E8F5E9;
  color: #1B5E20;
  border-color: #C8E6C9;
}

.warranty-expirada {
  background: #FFEBEE;
  color: #CC0000;
  border-color: #FFCDD2;
}

.warranty-por-vencer {
  background: #FFF8E1;
  color: #F57F17;
  border-color: #FFE082;
}

.warranty-loading {
  background: #F5F5F5;
  color: #9E9E9E;
  border-color: #E0E0E0;
}

.badge {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border: 1px solid;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.state-Recibido {
  color: var(--rec-text);
  background: var(--rec-bg);
  border-color: var(--rec-border);
}

.state-Diagnosticando {
  color: var(--diag-text);
  background: var(--diag-bg);
  border-color: var(--diag-border);
}

.state-Reparando {
  color: var(--rep-text);
  background: var(--rep-bg);
  border-color: var(--rep-border);
}

.state-Listo {
  color: var(--ready-text);
  background: var(--ready-bg);
  border-color: var(--ready-border);
}

.state-Entregado {
  color: var(--done-text);
  background: var(--done-bg);
  border-color: var(--done-border);
}

.text-button {
  display: block;
  min-height: 44px;
  margin: 0 auto;
  border: 0;
  background: transparent;
  color: var(--red);
  font-weight: 700;
  cursor: pointer;
}

.empty-card {
  max-width: 390px;
  margin: 64px auto 0;
  padding: 32px 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--white);
  box-shadow: var(--shadow);
  text-align: center;
}

.empty-icon {
  width: 64px;
  height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  border-radius: 50%;
  background: var(--red-soft);
  color: #EF5350;
}

.empty-icon svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.empty-card h1 {
  margin: 0 0 14px;
  font-size: 22px;
  line-height: 1.15;
}

.empty-card p {
  margin: 0 0 26px;
  line-height: 1.55;
}

.detail-layout {
  display: grid;
  grid-template-columns: 376px minmax(420px, 1fr);
  gap: 26px;
  align-items: start;
}

.detail-aside {
  display: grid;
  gap: 22px;
}

.ticket-summary,
.timeline-card,
.date-alert {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--white);
  box-shadow: var(--shadow);
}

.ticket-summary {
  padding: 26px 28px;
}

.ticket-summary h1 {
  margin: 0 0 16px;
  font-size: 20px;
}

.ticket-summary p {
  margin: 0 0 18px;
  font-weight: 700;
}

.date-alert {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--warning-bg);
  font-weight: 700;
}

.date-alert svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--red);
  stroke-width: 2;
  stroke-linecap: round;
}

.timeline-card {
  overflow: hidden;
}

.timeline-card header {
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
}

.timeline-card h2 {
  margin: 0;
  font-size: 20px;
}

.timeline {
  padding: 36px 42px 24px 80px;
}

.tl-step {
  position: relative;
  min-height: 110px;
  padding: 0 0 34px 42px;
}

.tl-step:last-child {
  min-height: 0;
  padding-bottom: 0;
}

.tl-step::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 32px;
  bottom: -8px;
  width: 2px;
  background: var(--success);
}

.tl-step.pending::before {
  background: var(--border);
}

.tl-step:last-child::before {
  display: none;
}

.tl-dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--white);
  color: var(--border);
}

.tl-dot.done,
.tl-dot.active {
  color: var(--success);
  border-color: var(--success);
}

.tl-dot.repair {
  color: var(--red);
  border-color: transparent;
}

.tl-dot svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tl-body {
  max-width: 560px;
}

.tl-title {
  margin: 0 0 10px;
  color: var(--success);
  font-size: 16px;
  font-weight: 700;
}

.tl-step.active .tl-body {
  padding: 22px;
  border: 2px solid var(--rep-border);
  border-radius: var(--radius-card);
  background: var(--rep-bg);
}

.tl-step.active .tl-title {
  color: var(--text);
}

.tl-step.pending .tl-title {
  color: var(--muted);
}

.tl-desc {
  margin: 0;
  line-height: 1.55;
}

.detail-return {
  margin-top: 22px;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: min(12vw, 96px);
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
  background: var(--white);
  color: #B0B0B0;
}

.bottom-item {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.bottom-item.active {
  color: var(--red);
  border-top: 3px solid var(--red);
  margin-top: -17px;
  padding-top: 14px;
}

body.mode-results .brand,
body.mode-detail .brand,
body.mode-empty .brand {
  text-align: left;
}

body.mode-results .brand strong,
body.mode-detail .brand strong,
body.mode-empty .brand strong {
  display: inline;
  margin-right: 6px;
  font-size: 18px;
}

body.mode-results .brand span,
body.mode-detail .brand span,
body.mode-empty .brand span {
  display: inline;
  font-size: 16px;
  letter-spacing: 0.02em;
}

body.mode-results .app-header,
body.mode-detail .app-header,
body.mode-empty .app-header {
  justify-content: flex-start;
}

body.mode-results .header-back,
body.mode-detail .header-back,
body.mode-empty .header-back {
  display: inline-grid;
}

body.mode-results .brand,
body.mode-detail .brand,
body.mode-empty .brand {
  margin-left: 48px;
}

body.mode-results .outline-top,
body.mode-detail .outline-top {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 900px) {
  .app-header {
    justify-content: flex-start;
    min-height: 76px;
    padding-left: max(32px, calc((100vw - 1120px) / 2));
    padding-right: max(32px, calc((100vw - 1120px) / 2));
  }

  .brand {
    text-align: left;
  }

  .brand strong {
    display: inline;
    margin-right: 8px;
    font-size: 20px;
  }

  .brand span {
    display: inline;
    font-size: 18px;
    letter-spacing: 0.02em;
  }

  .shell {
    padding-top: 52px;
  }

  .view-search {
    max-width: 460px;
    margin: 0 auto;
  }

  .bottom-nav {
    display: none;
  }

  .hero h1 {
    font-size: 30px;
  }

  /* Desktop: ocultar cards, mostrar tabla */
  .result-grid {
    display: none;
  }

  .results-table-wrap {
    display: block;
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(375px, calc(100% - 28px));
    padding-top: 24px;
  }

  .app-header {
    min-height: 58px;
  }

  .brand strong {
    font-size: 22px;
  }

  .brand span {
    font-size: 14px;
  }

  body.mode-results .outline-top,
  body.mode-detail .outline-top {
    display: none;
  }

  .result-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .timeline {
    padding: 28px 24px 24px 30px;
  }

  .tl-step {
    padding-left: 36px;
  }

  .empty-card {
    margin-top: 82px;
  }
}

.nps-dialog {
  width: min(560px, calc(100% - 32px));
  border: 0;
  border-radius: 24px;
  padding: 0;
  box-shadow: 0 28px 80px rgba(20, 20, 30, 0.28);
}

.nps-dialog::backdrop {
  background: rgba(18, 20, 28, 0.62);
  backdrop-filter: blur(5px);
}

.nps-form {
  position: relative;
  display: grid;
  gap: 18px;
  padding: 34px;
}

.nps-form h2 {
  margin: 0;
  font-size: clamp(22px, 4vw, 30px);
}

.nps-kicker {
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nps-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #f2f3f6;
  cursor: pointer;
}

.nps-scale {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
}

.nps-score {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  font-weight: 800;
  cursor: pointer;
  transition: 160ms ease;
}

.nps-score:hover,
.nps-score.selected {
  border-color: var(--red);
  background: var(--red);
  color: var(--white);
  transform: translateY(-2px);
}

.nps-scale-labels {
  display: flex;
  justify-content: space-between;
  margin-top: -12px;
  color: #777;
  font-size: 12px;
}

.nps-form textarea {
  resize: vertical;
  min-height: 96px;
}

.nps-message {
  margin: 0;
  color: var(--red);
  font-weight: 700;
}

.nps-message.success {
  color: #177245;
}

@media (max-width: 560px) {
  .nps-form { padding: 28px 20px 22px; }
  .nps-scale { grid-template-columns: repeat(5, 1fr); }
}

html { scroll-behavior: smooth; scrollbar-color: #b8bdc7 #f2f3f6; }
button, input, textarea, select, .ticket-result, .timeline-card {
  transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease,
    box-shadow 180ms ease, transform 180ms ease;
}
button:hover:not(:disabled) { transform: translateY(-1px); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible,
.ticket-result:focus-visible {
  outline: 3px solid rgba(204, 0, 0, 0.22);
  outline-offset: 3px;
}
