:root {
  color-scheme: light;
  --ink: #15202b;
  --muted: #5f6b77;
  --line: #d6dee7;
  --line-strong: #bdc9d6;
  --paper: rgba(255, 255, 255, 0.9);
  --paper-strong: #ffffff;
  --soft: #f4f7fb;
  --soft-green: #e8f4ef;
  --green: #1a7a63;
  --green-dark: #0f5f4d;
  --navy: #183247;
  --amber: #c47d12;
  --red: #b42318;
  --shadow-lg: 0 28px 80px rgba(22, 37, 52, 0.12);
  --shadow-md: 0 16px 38px rgba(22, 37, 52, 0.08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(56, 124, 102, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(24, 50, 71, 0.12), transparent 26%),
    linear-gradient(135deg, #f3f7fb 0%, #edf3f7 44%, #f8fbfd 100%);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(20, 32, 43, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 32, 43, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  mask-image: radial-gradient(circle at center, black 45%, transparent 100%);
}

button, input, select, textarea { font: inherit; }

.app {
  width: min(1520px, calc(100% - 20px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 0 28px;
  display: grid;
  grid-template-columns: minmax(760px, 1.2fr) minmax(420px, 0.8fr);
  gap: 20px;
  align-items: start;
  position: relative;
  z-index: 1;
}

.stack, .view { display: grid; gap: 18px; }
.view { display: none; }
.view.active { display: grid; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(189, 201, 214, 0.8);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: #385064;
  border-radius: 999px;
  min-height: 42px;
  padding: 0 18px;
  font-size: 13px;
  font-weight: 850;
}

.tab.active {
  background: linear-gradient(135deg, var(--navy), #204762);
  border-color: rgba(18, 40, 57, 0.18);
  color: #fff;
  box-shadow: 0 12px 24px rgba(24, 50, 71, 0.2);
}

.hero {
  padding: 22px 24px 16px;
  border: 1px solid rgba(197, 208, 218, 0.72);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at top right, rgba(26, 122, 99, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(247, 250, 252, 0.92));
  box-shadow: var(--shadow-md);
}

.eyebrow {
  margin: 0;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 10px 0 12px;
  max-width: 780px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 0.92;
  letter-spacing: -0.03em;
}

.hero p {
  margin: 0;
  max-width: 760px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.62;
}

.panel {
  border: 1px solid rgba(198, 208, 217, 0.82);
  background: var(--paper);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-xl);
}

.form {
  padding: 18px;
  display: grid;
  gap: 14px;
}

label { display: grid; gap: 8px; }

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.label-text {
  color: #20303d;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

textarea, input, select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  outline: none;
  padding: 12px 14px;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease, transform 140ms ease;
}

textarea { min-height: 128px; resize: vertical; }
.compact-area { min-height: 120px; }
.helper-text {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

textarea:focus, input:focus, select:focus {
  border-color: var(--green);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(26, 122, 99, 0.14);
  transform: translateY(-1px);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.compact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.message-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.message-textareas {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.message-form textarea {
  min-height: 94px;
}

.message-form .preset-note {
  padding: 8px 10px;
}

#vistaNotas textarea,
#vistaRubricas textarea {
  min-height: 100px;
}

.inline-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.align-end {
  align-items: end;
  justify-content: flex-end;
}

.preset-note {
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(232, 244, 239, 0.95), rgba(243, 249, 246, 0.9));
  border: 1px solid #d2e6df;
  color: #1f5f50;
  font-size: 13px;
  line-height: 1.5;
}

.deliveries {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
}

.delivery {
  position: relative;
  min-height: 72px;
  border: 1px solid #cfd7e1;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #f8fbfd);
  cursor: pointer;
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 8px 6px;
  text-align: center;
  color: #26313d;
}

.delivery input { position: absolute; opacity: 0; pointer-events: none; }

.delivery span:first-of-type {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 900;
}

.delivery span:last-of-type {
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
}

.delivery:has(input:checked) {
  border-color: var(--green);
  background: linear-gradient(180deg, #ecf8f3, #e3f4ed);
  color: var(--green-dark);
  box-shadow: 0 0 0 3px rgba(26, 122, 99, 0.12);
}

.btn {
  border: 0;
  border-radius: 999px;
  min-height: 44px;
  padding: 0 18px;
  font-weight: 850;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease, box-shadow 120ms ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(24, 50, 71, 0.12);
}
.btn:disabled { cursor: not-allowed; opacity: 0.55; }

.primary {
  flex: 1;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: #fff;
}
.primary:hover:not(:disabled) { background: linear-gradient(135deg, #177660, #0c5848); }
.dark {
  background: linear-gradient(135deg, var(--navy), #21475f);
  color: #fff;
}
.ghost {
  border: 1px solid #c8d0db;
  background: rgba(255, 255, 255, 0.94);
  color: #26313d;
}
.mini { min-height: 32px; padding: 0 10px; font-size: 12px; }

.options-head, .result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
}

.status {
  min-height: 46px;
  border: 1px solid #d9e0e7;
  background: linear-gradient(180deg, rgba(249, 251, 253, 0.95), rgba(245, 248, 250, 0.95));
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.pixel-clock {
  width: 24px;
  height: 24px;
  border: 3px solid #182029;
  border-radius: 4px;
  position: relative;
  background: #f6d66b;
  box-shadow: inset 0 0 0 3px #fff2b5;
  flex: 0 0 auto;
}

.pixel-clock::before, .pixel-clock::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 8px;
  background: #182029;
  transform-origin: 50% 0;
}

.pixel-clock::before { animation: tick 1.1s steps(8) infinite; }
.pixel-clock::after { height: 6px; animation: tick 5.5s steps(8) infinite; }
.idle .pixel-clock::before, .idle .pixel-clock::after { animation-play-state: paused; }

@keyframes tick {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.timer {
  margin-left: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 800;
  color: #24303c;
}

.options {
  display: grid;
  gap: 10px;
}

.option {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 252, 0.95));
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 120ms ease;
}

.option:hover { border-color: var(--green); transform: translateY(-1px); }

.option.selected {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(26, 122, 99, 0.12);
}

.option-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.option h3 { margin: 0; font-size: 16px; }

.tag {
  border-radius: 999px;
  background: #eef3f7;
  color: #405262;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.option p { margin: 9px 0 0; color: var(--muted); line-height: 1.45; }
.option .product { color: var(--green-dark); font-size: 12px; font-weight: 850; text-transform: uppercase; }

.result-panel {
  padding: 16px;
  min-height: calc(100vh - 36px);
  position: sticky;
  top: 18px;
  background:
    radial-gradient(circle at top right, rgba(26, 122, 99, 0.08), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 251, 253, 0.94));
}
.result-title { display: grid; gap: 4px; }
.result-title p { margin: 0; color: var(--muted); font-size: 14px; }

.guard {
  border-radius: 999px;
  background: #fff1d8;
  color: #744a08;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 850;
}

.result-actions {
  margin-top: 16px;
  display: none;
  gap: 8px;
  flex-wrap: wrap;
}

.result-actions.visible { display: flex; }

.result {
  margin-top: 16px;
  min-height: 420px;
  border: 1px solid #d6dde5;
  border-radius: 18px;
  background: linear-gradient(180deg, #f7fafc, #f2f6f9);
  padding: 18px;
  color: #29323d;
  font-size: 14px;
  line-height: 1.6;
}

.guide { display: grid; gap: 14px; }

.guide-section {
  border: 1px solid #dde3ea;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  padding: 14px;
}

.guide-section h3 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  color: #1f2a35;
}

.guide-section p { margin: 0; }
.guide-section ol, .guide-section ul { margin: 8px 0 0; padding-left: 22px; }
.message-output { white-space: pre-wrap; font-size: 15px; line-height: 1.7; }
.rubric-list {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}
.rubric-item {
  border: 1px solid #dde3ea;
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(180deg, #fff, #fbfcfe);
}
.rubric-item h4 {
  margin: 0 0 6px;
  font-size: 14px;
}
.text-block {
  white-space: pre-wrap;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  border: 1px solid #b9d6cc;
  border-radius: 8px;
  background: #effaf5;
  color: #0f4e40;
  box-shadow: 0 16px 34px rgba(28, 39, 49, 0.16);
  padding: 12px 14px;
  font-weight: 800;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: transform 180ms ease, opacity 180ms ease;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: #f0b7b2; background: #fff1f0; color: var(--red); }

@media (max-width: 840px) {
  .app { grid-template-columns: 1fr; width: min(100% - 16px, 760px); padding: 14px 0 20px; }
  .grid-2 { grid-template-columns: 1fr; }
  .compact-grid { grid-template-columns: 1fr; }
  .message-fields { grid-template-columns: 1fr; }
  .message-textareas { grid-template-columns: 1fr; }
  .deliveries { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-panel { min-height: auto; position: static; }
  .result { min-height: 360px; }
  h1 { font-size: 38px; }
  .align-end { justify-content: stretch; }
  .hero { padding: 18px 16px 14px; }
  .tabs { padding: 8px; }
  .form { padding: 14px; }
}
