:root {
  --navy: #0B3954;
  --teal: #16A39A;
  --teal-d: #11857E;
  --green: #7BC67E;
  --red: #D64545;
  --bg: #F2F4F7;
  --card: #fff;
  --muted: #6b7280;
  --line: #d7dee4;
  --amber: #B7791F;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 15px/1.45 Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  background: var(--bg);
  color: #1d2939;
  padding-bottom: 88px;
}

.top {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--navy);
  color: #fff;
  padding: .7rem 1.1rem;
}
.brand { display: flex; align-items: baseline; gap: .55rem; font-weight: 800; }
.brand .sub { font-weight: 400; opacity: .78; font-size: .88rem; }
.pill {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  padding: .2rem .65rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  background: #ffffff22;
}
.pill.offline { background: #ffffff18; }

.stepper-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: .75rem 1.1rem .2rem;
}
.stepper-track {
  position: relative;
  height: 4px;
  border-radius: 999px;
  background: #d7dee4;
  margin: 0 .15rem .55rem;
  overflow: hidden;
}
.stepper-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--green));
  transition: width 420ms ease;
}
.stepper {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.stepper .stp {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .28rem .7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: #51616e;
  font-size: .82rem;
  cursor: pointer;
  min-height: 36px;
  position: relative;
  overflow: hidden;
  transition: color 220ms ease, border-color 220ms ease, background 220ms ease, transform 180ms ease;
}
.stepper .stp::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #BFE0D2, #E3F4E4);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 380ms ease;
  z-index: 0;
}
.stepper .stp > * { position: relative; z-index: 1; }
.stepper .stp b { font-weight: 700; }
.stepper .stp.cur {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(11, 57, 84, .18);
}
.stepper .stp.cur::before { transform: scaleX(0); background: transparent; }
.stepper .stp.done {
  background: #F2FAF5;
  border-color: #BFE0D2;
  color: #2F7A38;
}
.stepper .stp.done::before { transform: scaleX(1); }
.stepper .stp:disabled { opacity: .45; cursor: not-allowed; }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: .6rem 1.1rem 1.2rem;
}
h1 { margin: .2rem 0 .4rem; font-size: 1.45rem; color: var(--navy); }
.lead { margin: 0 0 1rem; color: var(--muted); }
.muted { color: var(--muted); }
.hint { margin: .5rem 0 0; font-size: .9rem; color: var(--teal-d); }
.stack { display: flex; flex-direction: column; gap: .7rem; }

.card {
  background: var(--card);
  border-radius: 10px;
  padding: .9rem 1rem;
  box-shadow: 0 1px 2px #0001;
  border: 1px solid #e8eef3;
}
.card.empty { border-style: dashed; text-align: center; padding: 1.4rem 1rem; }
.card h3 { margin: 0 0 .35rem; font-size: 1.02rem; color: var(--navy); }
.card .meta { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .45rem; }

.file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: .55rem 1.1rem;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  border: 0;
}
.file-btn input { display: none; }

.field {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  font-size: .85rem;
  color: #555;
  margin: .7rem 0;
}
input, select, textarea {
  font: inherit;
  padding: .5rem .6rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  width: 100%;
}
textarea { resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  min-height: 44px;
  padding: .55rem 1.05rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-d); border-color: var(--teal-d); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: #f0c2c0; background: #fff5f4; }
.btn.sm { min-height: 38px; padding: .35rem .7rem; font-size: .9rem; }
.btn.on { background: var(--navy); color: #fff; border-color: var(--navy); }

.bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: .6rem;
  justify-content: flex-end;
  padding: .75rem 1.1rem;
  background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px #0001;
  z-index: 20;
}
.bar #btn-back { margin-right: auto; }

.tag {
  display: inline-block;
  padding: .1rem .55rem;
  border-radius: 999px;
  background: #eef2f6;
  font-size: .78rem;
  font-weight: 600;
  color: #3b4a57;
}
.tag.ok { background: #E3F4E4; color: #2F7A38; }
.tag.warn { background: #fff3d6; color: var(--amber); }
.tag.bad { background: #fde2e0; color: var(--red); }
.tag.nuevo { background: #E6F7F5; color: var(--teal-d); }
.tag.modifica, .tag.modificado { background: #FFF4D6; color: #8a5a00; }
.tag.deroga { background: #fde2e0; color: var(--red); }
.tag.ratifica { background: #E3F4E4; color: #2F7A38; }
.tag.no_aplica { background: #eef2f6; color: #51616e; }

blockquote.cita {
  margin: .45rem 0;
  padding: .45rem .7rem;
  border-left: 3px solid var(--teal);
  background: #f3f7fa;
  font-size: .9rem;
  color: #333;
}

.row { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .55rem; }
.stamp { font-size: .8rem; color: var(--muted); margin-top: .35rem; }

.filters { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 .7rem; }
.filters .chip {
  min-height: 36px;
  padding: .25rem .7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font: inherit;
  font-size: .85rem;
}
.filters .chip.on { background: var(--teal); color: #fff; border-color: var(--teal); }

.ticker {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .45rem;
}
.ticker li {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .65rem .8rem;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  transition: background 200ms ease, border-color 200ms ease, color 200ms ease;
}
.ticker li .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: #d0d7de; flex: 0 0 auto;
  transition: background 200ms ease, box-shadow 200ms ease;
}
.ticker li.run { color: var(--navy); border-color: #b7e0db; background: #F0FAF9; }
.ticker li.run .dot { background: var(--teal); box-shadow: 0 0 0 4px #16a39a33; }
.ticker li.done { color: #2F7A38; border-color: #BFE0D2; background: #F2FAF5; }
.ticker li.done .dot { background: var(--green); }

/* Step 3: 6 fake cubes (mini pipeline) */
.cubes {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin: 0 0 .85rem;
  padding: .7rem .8rem;
  background: var(--navy);
  border-radius: 10px;
  min-height: 52px;
  align-items: center;
}
.cube {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: #9AA8B5;
  opacity: .35;
  transform: scale(.85);
  transition: background 280ms ease, opacity 280ms ease, transform 280ms ease, box-shadow 280ms ease;
}
.cube.on {
  opacity: 1;
  transform: scale(1);
  box-shadow: 0 0 0 3px rgba(22, 163, 154, .28);
}
.cube.c0.on { background: #7BE3D9; }
.cube.c1.on { background: #9DB9FF; }
.cube.c2.on { background: var(--teal); }
.cube.c3.on { background: #FFD59E; }
.cube.c4.on { background: var(--green); }
.cube.c5.on { background: #4ADE80; animation: cube-pulse 1.1s ease-in-out infinite; }

@keyframes cube-pulse {
  50% { transform: scale(1.08); box-shadow: 0 0 0 5px rgba(74, 222, 128, .35); }
}

/* HITL rows fade-in */
#hitl-list .card.fade-in {
  animation: row-fade 320ms ease both;
}
@keyframes row-fade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Impact cards slide by clase */
#impact-list .card.slide-in {
  animation: card-slide 380ms ease both;
  border-left: 4px solid var(--slide-color, var(--teal));
}
#impact-list .card.slide-in.modifica { --slide-color: #B7791F; }
#impact-list .card.slide-in.nuevo { --slide-color: var(--teal); }
#impact-list .card.slide-in.deroga { --slide-color: var(--red); }
#impact-list .card.slide-in.ratifica { --slide-color: #2F7A38; }
#impact-list .card.slide-in.no_aplica { --slide-color: #51616e; }
@keyframes card-slide {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: none; }
}

/* Publish button pulse when ready */
.btn.primary.pulse:not(:disabled) {
  animation: pub-pulse 1.4s ease-in-out infinite;
}
@keyframes pub-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 154, .45); }
  50% { box-shadow: 0 0 0 8px rgba(22, 163, 154, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .stepper-fill, .stepper .stp, .stepper .stp::before,
  .ticker li, .cube, #hitl-list .card.fade-in,
  #impact-list .card.slide-in, .btn.primary.pulse:not(:disabled) {
    animation: none !important;
    transition: none !important;
  }
  .stepper .stp.done::before { transform: scaleX(1); }
  .cube.on { opacity: 1; transform: none; }
}

.sug-field {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: .35rem .8rem;
  align-items: start;
}
.sug-field .k { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; padding-top: .15rem; }
.sug-field .v { font-weight: 600; color: var(--navy); }
.confirm-row { margin-top: .5rem; }

.done-msg {
  margin-top: 1rem;
  padding: 1rem;
  background: #F2FAF5;
  border: 1px solid #BFE0D2;
  border-radius: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  align-items: center;
  font-weight: 600;
  color: #2F7A38;
}

dialog {
  border: 0;
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  max-width: 460px;
  width: calc(100% - 2rem);
  box-shadow: 0 12px 40px #0003;
}
dialog::backdrop { background: #0B395466; }
dialog h2 { margin: 0 0 .6rem; color: var(--navy); font-size: 1.15rem; }
.dlg-actions { display: flex; justify-content: flex-end; gap: .45rem; margin-top: .8rem; }

@media (max-width: 640px) {
  .sug-field { grid-template-columns: 1fr; }
  .brand .sub { display: none; }
}
