:root {
  --page: #edf2f6;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --ink: #26384a;
  --muted: #687c91;
  --line: #d4dfe8;
  --line-strong: #c2d0dc;
  --entry: #f0f3f5;
  --entry-ink: #536474;
  --review: #fff6c9;
  --review-ink: #675200;
  --prepare: #e8f2fb;
  --prepare-ink: #315f86;
  --delivery: #e8f5ec;
  --delivery-ink: #356d49;
  --issue: #fbe8e5;
  --issue-ink: #9a493f;
  --done: #eaf5ee;
  --done-ink: #3e7551;
  --shadow: 0 12px 32px rgba(34, 57, 77, .08);
  --radius: 12px;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--page); }
body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(73, 125, 168, .22);
  outline-offset: 2px;
}
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.45), transparent 42%),
    var(--page);
}
.login-card {
  width: min(390px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.eyebrow, .section-label {
  margin: 0 0 6px;
  color: #66809a;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .11em;
}
.login-card h1 { margin: 0; font-size: 26px; letter-spacing: -.025em; }
.login-help { margin: 7px 0 25px; color: var(--muted); }
.login-card label, .reason-field { display: grid; gap: 7px; margin-top: 15px; }
.login-card label span, .reason-field span { font-size: 12px; font-weight: 700; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}
input { height: 42px; padding: 0 12px; }
textarea { padding: 10px 12px; resize: vertical; }
.login-card .primary { width: 100%; margin-top: 22px; }
.privacy-note { margin: 14px 0 0; color: var(--muted); font-size: 11px; text-align: center; }
.form-error { min-height: 18px; margin: 9px 0 0; color: #9d3d36; font-size: 12px; }

.app {
  width: min(1900px, calc(100% - 36px));
  min-height: calc(100vh - 36px);
  margin: 18px auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.topbar {
  min-height: 70px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.topbar p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.session-meta { display: flex; align-items: center; gap: 9px; margin-right: 5px; font-size: 11px; }
.session-meta span { color: var(--muted); }
.session-meta span.connection-error { color: var(--issue-ink); font-weight: 700; }
.session-meta strong::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #72a17f; }

.button {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.button:hover { border-color: #9eb1c2; }
.button:disabled { opacity: .55; cursor: wait; }
.button.primary { min-width: 150px; }
.button.primary.neutral { border-color: #516a80; color: #fff; background: #516a80; }
.button.primary.review { border-color: #e0b900; color: #574700; background: #fff2a8; }
.button.primary.preparation { border-color: #76a4c8; color: #254f72; background: #e2f0fa; }
.button.primary.delivery { border-color: #74a987; color: #285f3c; background: #e5f4ea; }
.button.primary.issue { border-color: #cc8177; color: #893d34; background: #fbe8e5; }
.button.quiet { min-width: 0; background: #fff; color: #52677b; }
.button.quiet.active { border-color: #6f8ba2; color: #294e6a; background: #e7f0f6; }
.text-button {
  padding: 4px 0;
  border: 0;
  border-bottom: 1px solid #93aabd;
  color: #42627d;
  background: transparent;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.stage-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.stage {
  min-height: 98px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 0;
  border-right: 1px solid var(--line);
  background: #fff;
  text-align: left;
  cursor: pointer;
}
.stage:last-child { border-right: 0; }
.stage.entry { background: var(--entry); }
.stage.review { background: var(--review); }
.stage.preparation { background: var(--prepare); }
.stage.delivery { background: var(--delivery); }
.stage.active { box-shadow: inset 0 -4px 0 #6d8295; }
.stage.entry.active { box-shadow: inset 0 -4px 0 #8695a2; }
.stage.review.active { box-shadow: inset 0 -4px 0 #e1b800; }
.stage.preparation.active { box-shadow: inset 0 -4px 0 #6b9dc2; }
.stage.delivery.active { box-shadow: inset 0 -4px 0 #6fa17f; }
.stage-number { min-width: 24px; font-size: 30px; font-weight: 700; line-height: 1; }
.stage strong { display: block; font-size: 13px; }
.stage small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }

.workspace { display: grid; grid-template-columns: minmax(620px, 1.45fr) minmax(420px, .75fr); min-height: calc(100vh - 187px); }
.queue { min-width: 0; border-right: 1px solid var(--line); }
.queue-header {
  min-height: 67px;
  padding: 15px 18px 10px;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}
.queue-header h2 { margin: 0; font-size: 16px; }
.queue-header p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.table-head, .order-row {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1.12fr .62fr .95fr;
  align-items: center;
  column-gap: 16px;
}
.table-head {
  min-height: 36px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  color: #6e8297;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.order-list { max-height: calc(100vh - 300px); overflow-y: auto; }
.order-row {
  width: 100%;
  min-height: 67px;
  padding: 10px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  text-align: left;
  cursor: pointer;
}
.order-row:hover { background: #f8fafb; }
.order-row.selected { box-shadow: inset 5px 0 0 #718496; }
.order-row.tone-neutral.selected { background: #edf1f4; box-shadow: inset 5px 0 0 #718496; }
.order-row.tone-review.selected { background: #fff1a8; box-shadow: inset 5px 0 0 #d3a900; }
.order-row.tone-preparation.selected { background: #dcecf8; box-shadow: inset 5px 0 0 #4f8ab5; }
.order-row.tone-delivery.selected, .order-row.tone-done.selected { background: #dcefe2; box-shadow: inset 5px 0 0 #57906a; }
.order-row.tone-issue.selected { background: #f9dfdb; box-shadow: inset 5px 0 0 #b35c51; }
.order-row.selected .order-cell strong { color: var(--ink); }
.order-cell { min-width: 0; }
.order-cell strong { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 12px; white-space: nowrap; }
.order-cell small { display: block; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.order-cell.amount strong { font-size: 12px; }
.status-pill {
  display: inline-flex;
  max-width: 100%;
  min-height: 25px;
  padding: 5px 9px;
  align-items: center;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
}
.status-pill.neutral { background: var(--entry); color: var(--entry-ink); }
.status-pill.review { background: var(--review); color: var(--review-ink); }
.status-pill.preparation { background: var(--prepare); color: var(--prepare-ink); }
.status-pill.delivery, .status-pill.done { background: var(--delivery); color: var(--delivery-ink); }
.status-pill.issue { background: var(--issue); color: var(--issue-ink); }
.queue-loading { padding: 66px 22px; color: var(--muted); text-align: center; }
.queue-loading strong { display: block; margin-top: 12px; color: var(--ink); }
.queue-loading p { margin: 6px 0 0; font-size: 12px; }
.loading-spinner {
  width: 24px;
  height: 24px;
  margin: 0 auto;
  display: block;
  border: 3px solid #dce5eb;
  border-top-color: #66849b;
  border-radius: 50%;
  animation: queue-spin .75s linear infinite;
}
@keyframes queue-spin { to { transform: rotate(360deg); } }
.empty-state { padding: 70px 22px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); }
.empty-state p { margin: 6px 0 0; font-size: 12px; }

.detail { min-width: 0; background: #fff; }
.detail.completed { background: #f1faf4; }
.detail.completed .detail-header { background: #d8f0df; border-bottom-color: #9dceb0; }
.detail.completed .status-pill.done { color: #245f38; background: #bfe5ca; }
.detail-empty { min-height: 460px; padding: 60px 28px; display: grid; place-content: center; text-align: center; }
.empty-mark { width: 46px; height: 46px; margin: 0 auto 13px; display: grid; place-items: center; border-radius: 50%; color: #6c8397; background: #eef3f6; font-size: 20px; }
.detail-empty h2 { margin: 0; font-size: 17px; }
.detail-empty p { max-width: 270px; margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.detail-content { max-height: calc(100vh - 187px); overflow-y: auto; }
.detail-header {
  padding: 17px 18px;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 15px;
  border-bottom: 1px solid var(--line);
}
.detail-header h2 { margin: 0; font-size: 18px; letter-spacing: -.015em; }
.detail.loading-detail #detailTitle::before {
  content: "";
  width: 14px;
  height: 14px;
  margin-right: 8px;
  display: inline-block;
  vertical-align: -2px;
  border: 2px solid #dce5eb;
  border-top-color: #66849b;
  border-radius: 50%;
  animation: queue-spin .75s linear infinite;
}
.detail-header > div > p:last-child { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.notice { margin: 12px 18px 0; padding: 10px 12px; border: 1px solid #bfdac7; border-radius: 7px; color: #3e704e; background: #edf7f0; font-size: 11px; }
.notice.error { border-color: #e6bbb5; color: #92463e; background: #fdf0ee; }
.action-section {
  margin: 0 18px;
  padding: 14px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}
.action-section h3 { margin: 0; font-size: 13px; }
.review-layout { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); margin: 0 18px; border-bottom: 1px solid var(--line); }
.voucher-column, .payment-column { min-width: 0; padding: 15px 0; }
.voucher-column { padding-right: 14px; border-right: 1px solid var(--line); }
.payment-column { padding-left: 14px; }
.section-heading { margin-bottom: 10px; display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.section-heading h3 { margin: 0; font-size: 13px; }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.mini-state { padding: 4px 7px; border-radius: 999px; color: var(--muted); background: var(--entry); font-size: 9px; font-weight: 700; }
.voucher-preview {
  width: 100%;
  height: 200px;
  padding: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 10px;
  cursor: zoom-in;
}
.voucher-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.payment-alert { margin-bottom: 8px; padding: 9px 10px; border-radius: 7px; font-size: 10px; line-height: 1.45; }
.payment-alert.neutral { color: var(--entry-ink); background: var(--entry); }
.payment-alert.review { color: var(--review-ink); background: var(--review); }
.payment-alert.issue { color: var(--issue-ink); background: var(--issue); }
.payment-alert.done { color: var(--done-ink); background: var(--done); }
.data-grid { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 14px; }
.datum { min-width: 0; padding: 8px 0; border-bottom: 1px solid #e2e9ee; }
.datum dt { color: #74889b; font-size: 8px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.datum dd { margin: 3px 0 0; overflow-wrap: anywhere; font-size: 11px; font-weight: 700; }
.content-section { margin: 0 18px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.section-total { color: #5f7489; font-size: 10px; }
.product-list { display: grid; }
.product-row { min-height: 54px; padding: 8px 0; display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 10px; border-bottom: 1px solid #e3e9ee; }
.product-row:last-child { border-bottom: 0; }
.product-image { width: 40px; height: 40px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; color: #70869b; background: #f2f6f8; font-size: 8px; text-align: center; }
.product-image img { width: 100%; height: 100%; object-fit: cover; object-position: center; }
.product-info strong { display: block; font-size: 11px; }
.product-info small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.product-price { font-size: 11px; font-weight: 700; }
.fold-section { margin: 0 18px; border-bottom: 1px solid var(--line); }
.fold-button { width: 100%; min-height: 45px; padding: 0; display: flex; align-items: center; justify-content: space-between; border: 0; background: #fff; font-size: 11px; font-weight: 700; cursor: pointer; }
.fold-icon { color: #63798d; font-size: 16px; }
.fold-body { padding: 0 0 13px; }
.history-list { margin: 0; padding: 0 0 0 18px; }
.history-list li { padding: 7px 0 7px 4px; color: var(--muted); font-size: 11px; }
.history-list strong { display: block; color: var(--ink); font-size: 11px; }
.secondary-actions { margin: 0 18px; padding: 13px 0 18px; }
.secondary-menu { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 7px; }
.secondary-menu button { min-height: 31px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: #526b81; font-size: 10px; font-weight: 700; cursor: pointer; }
.secondary-menu button.danger { border-color: #e3bab4; color: #94473e; background: #fff7f6; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  padding: 20px;
  display: grid;
  place-items: center;
  background: rgba(20, 32, 44, .62);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.modal-card { position: relative; width: min(960px, 100%); max-height: calc(100vh - 40px); overflow: auto; border: 1px solid rgba(255,255,255,.6); border-radius: 13px; background: #fff; box-shadow: 0 24px 70px rgba(12, 25, 37, .3); }
.modal-card.compact { width: min(430px, 100%); padding: 22px; }
.modal-card h2 { margin: 0; font-size: 19px; }
.modal-help { margin: 7px 38px 0 0; color: var(--muted); font-size: 12px; }
.incident-options { margin-top: 18px; display: grid; gap: 8px; }
.incident-option { min-height: 48px; padding: 8px 12px; display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; text-align: left; cursor: pointer; }
.incident-option strong { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--entry); }
.incident-option.issue strong { color: var(--issue-ink); background: var(--issue); }
.incident-option span { font-size: 12px; font-weight: 700; }
.modal-card input[type="search"] { text-transform: uppercase; }
.modal-close { width: 34px; height: 34px; position: absolute; top: 14px; right: 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: #607588; font-size: 21px; cursor: pointer; }
.state-change { margin-top: 14px; padding: 12px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; border-radius: 8px; background: #f3f6f8; font-size: 11px; font-weight: 700; text-align: center; }
.state-change strong { color: #6b8194; }
.modal-actions { margin-top: 19px; display: flex; justify-content: flex-end; gap: 8px; }
.voucher-card > header { min-height: 66px; padding: 14px 60px 12px 18px; border-bottom: 1px solid var(--line); }
.voucher-card > header h2 { font-size: 16px; }
.voucher-modal-body { min-height: 420px; padding: 18px; display: grid; place-items: center; background: #f2f5f7; }
.voucher-modal-body img { max-width: 100%; max-height: calc(100vh - 150px); object-fit: contain; }
.voucher-modal-body iframe { width: 100%; min-height: calc(100vh - 150px); border: 0; background: #fff; }
.voucher-modal-body p { color: var(--muted); }

@media (min-width: 1500px) {
  .workspace { grid-template-columns: minmax(800px, 1.55fr) minmax(500px, .75fr); }
  .order-list { max-height: calc(100vh - 298px); }
  .voucher-preview { height: 220px; }
}

@media (max-width: 1080px) {
  .app { width: calc(100% - 20px); margin: 10px auto; min-height: calc(100vh - 20px); }
  .workspace { grid-template-columns: minmax(520px, 1fr) minmax(380px, .82fr); }
  .stage { padding: 14px 12px; gap: 9px; }
  .stage-number { font-size: 25px; }
  .table-head, .order-row { grid-template-columns: 1.1fr 1fr .95fr .6fr; }
  .table-head span:nth-child(3), .order-row .order-cell:nth-child(3) { display: none; }
}

@media (max-width: 820px) {
  .app { width: 100%; min-height: 100vh; margin: 0; border: 0; border-radius: 0; }
  .topbar { padding: 12px 14px; }
  .topbar p, .session-meta span { display: none; }
  .stage-nav { grid-template-columns: repeat(4, minmax(150px, 1fr)); overflow-x: auto; }
  .stage { min-height: 82px; }
  .workspace { display: block; min-height: 0; }
  .queue { border-right: 0; }
  .order-list { max-height: none; }
  .detail { border-top: 8px solid var(--page); }
  .detail-content { max-height: none; }
  .review-layout { grid-template-columns: 1fr; }
  .voucher-column { padding-right: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .payment-column { padding-left: 0; }
}

@media (max-width: 560px) {
  body { font-size: 13px; }
  .topbar h1 { font-size: 17px; }
  .topbar { align-items: flex-start; flex-wrap: wrap; }
  .topbar-actions { width: 100%; justify-content: flex-start; }
  .session-meta { display: none; }
  .button { padding: 0 10px; }
  .stage-nav { grid-template-columns: repeat(4, 142px); }
  .stage strong { font-size: 11px; }
  .stage small { font-size: 9px; }
  .queue-header { padding-left: 13px; padding-right: 13px; }
  .table-head { display: none; }
  .order-row { min-height: 73px; padding: 11px 13px; grid-template-columns: 1fr auto; gap: 8px 14px; }
  .order-row .order-cell:nth-child(3), .order-row .order-cell:nth-child(4) { display: none; }
  .order-row .order-cell:last-child { grid-column: 2; grid-row: 1 / span 2; }
  .detail-header, .notice, .action-section, .review-layout, .content-section, .fold-section, .secondary-actions { margin-left: 13px; margin-right: 13px; }
  .detail-header { padding-left: 0; padding-right: 0; }
  .action-section { grid-template-columns: 1fr; }
  .action-section .primary { width: 100%; }
  .data-grid { grid-template-columns: 1fr; }
  .voucher-preview { height: 240px; }
  .modal { padding: 10px; }
  .modal-card.compact { padding: 20px 16px; }
  .state-change { grid-template-columns: 1fr; }
  .modal-actions .button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .loading-spinner { animation: none; }
}

/* V29: campo de código de agencia y mensajes de WhatsApp. */
#agencyCodeField small{display:block;margin-top:7px;color:var(--muted);font-size:10px;line-height:1.45}
#agencyCodeInput{text-transform:uppercase;letter-spacing:.08em;font-weight:700}
